Skip to content

Instantly share code, notes, and snippets.

@zokier
Created August 23, 2014 17:33
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zokier/30b77638cd4299f09337 to your computer and use it in GitHub Desktop.
Save zokier/30b77638cd4299f09337 to your computer and use it in GitHub Desktop.
ubuntu@ip-10-74-149-134:~$ mkdir rust-buildbox
ubuntu@ip-10-74-149-134:~$ cd rust-buildbox/
ubuntu@ip-10-74-149-134:~/rust-buildbox$ vim Dockerfile
ubuntu@ip-10-74-149-134:~/rust-buildbox$ docker build -t rust-buildbox .
ubuntu@ip-10-74-149-134:~/rust-buildbox$ docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
rust-buildbox latest be231641cce2 18 seconds ago 1.277 GB
ubuntu 14.04 c4ff7513909d 11 days ago 213 MB
ubuntu@ip-10-74-149-134:~/rust-buildbox$ docker run -t -i rust-buildbox /bin/bash
root@45ac8578f983:/# cd /home/rust/
root@45ac8578f983:/home/rust# git clone https://github.com/MatejLach/webapp.git
Cloning into 'webapp'...
remote: Counting objects: 5, done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 5 (delta 0), reused 5 (delta 0)
Unpacking objects: 100% (5/5), done.
Checking connectivity... done.
root@45ac8578f983:/home/rust# cd webapp/
root@45ac8578f983:/home/rust/webapp# cargo build
Updating git repository `https://github.com/nickel-org/nickel.rs.git`
Updating git repository `https://github.com/chris-morgan/anymap.git`
Updating git repository `https://github.com/servo/rust-url.git`
Updating git repository `https://github.com/lifthrasiir/rust-encoding`
Updating git repository `https://github.com/chris-morgan/rust-http.git`
Updating git repository `https://github.com/sfackler/rust-openssl.git`
Compiling openssl v0.0.0 (https://github.com/sfackler/rust-openssl.git#aba30b53)
Compiling anymap v0.9.0 (https://github.com/chris-morgan/anymap.git#7dc36adf)
Compiling encoding v0.1.0 (https://github.com/lifthrasiir/rust-encoding#a5505386)
Compiling url v0.1.0 (https://github.com/servo/rust-url.git#dfd4376e)
Compiling http v0.1.0-pre (https://github.com/chris-morgan/rust-http.git#b7f2fe74)
Compiling nickel v0.1.0 (https://github.com/nickel-org/nickel.rs.git#389a7c46)
Compiling webapp-demo v0.1.0 (file:///home/rust/webapp)
root@45ac8578f983:/home/rust/webapp#
... switch back to host system ...
ubuntu@ip-10-74-149-134:~/rust-buildbox$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
45ac8578f983 rust-buildbox:latest "/bin/bash" 8 minutes ago Up 8 minutes prickly_leakey
ubuntu@ip-10-74-149-134:~/rust-buildbox$ cd ..
ubuntu@ip-10-74-149-134:~$ mkdir webapp-demo
ubuntu@ip-10-74-149-134:~$ cd webapp-demo/
ubuntu@ip-10-74-149-134:~/webapp-demo$ docker cp 45ac8578f983:/home/rust/webapp/target/webapp-demo .
ubuntu@ip-10-74-149-134:~/webapp-demo$ vim Dockerfile
ubuntu@ip-10-74-149-134:~/webapp-demo$ docker build -t webapp-demo .
ubuntu@ip-10-74-149-134:~/webapp-demo$ docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
webapp-demo latest 8aa83bc48c9c About a minute ago 216.2 MB
rust-buildbox latest be231641cce2 37 minutes ago 1.277 GB
ubuntu 14.04 c4ff7513909d 11 days ago 213 MB
ubuntu@ip-10-74-149-134:~/webapp-demo$ docker run -d -p 80:8080 webapp-demo
ae1902a18b6defb37a14647c6ed2312ef6c70c37a02fad76e16a0b5e94748df6
ubuntu@ip-10-74-149-134:~/webapp-demo$ docker ps -l
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
ae1902a18b6d webapp-demo:latest "/opt/webapp/webapp- 30 seconds ago Up 29 seconds 0.0.0.0:80->8080/tcp hopeful_stallman
ubuntu@ip-10-74-149-134:~/webapp-demo$ curl http://localhost && echo
What the...a Rust-powered web app?
FROM ubuntu:14.04
MAINTAINER Torste Aikio <zokier@gmail.com>
RUN (apt-get -qq update && apt-get -qqy install curl git tar gzip gcc libssl-dev shared-mime-info)
RUN (mkdir /home/rust && cd /home/rust)
RUN export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/lib
RUN curl -O https://static.rust-lang.org/dist/rust-nightly-x86_64-unknown-linux-gnu.tar.gz
RUN tar xf rust-nightly-x86_64-unknown-linux-gnu.tar.gz
RUN ./rust-nightly-x86_64-unknown-linux-gnu/install.sh
RUN curl -O http://static.rust-lang.org/cargo-dist/cargo-nightly-x86_64-unknown-linux-gnu.tar.gz
RUN tar xf cargo-nightly-x86_64-unknown-linux-gnu.tar.gz
RUN ./cargo-nightly-x86_64-unknown-linux-gnu/install.sh
RUN rm -rf rust-nightly-x86_64-unknown-linux-gnu/
RUN rm -rf cargo-nightly-x86_64-unknown-linux-gnu/
FROM ubuntu:14.04
MAINTAINER Torste Aikio <zokier@gmail.com>
ADD webapp-demo /opt/webapp/webapp-demo
ENTRYPOINT ["/opt/webapp/webapp-demo"]
CMD []
EXPOSE 8080
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment