Skip to content

Commit

Permalink
feat: Add Dockerfile (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyo authored May 15, 2018
1 parent 60d0b7d commit 429de42
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.dockerignore
.git
.vscode
.*.swp
.travis*
*.pyc
target/
cabi/target
Dockerfile
py/venv
38 changes: 38 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
FROM ubuntu:14.04

ENV BUILD_TARGET=x86_64-unknown-linux-gnu
ENV RUST_TOOLCHAIN=stable
ENV OPENSSL_ARCH=linux-x86_64
ENV OPENSSL_DIR=/usr/local/build/$BUILD_TARGET
ENV OPENSSL_STATIC=1

RUN apt-get update \
&& apt-get install -y curl build-essential

# Compile static OpenSSL
COPY scripts/prepare-build.sh /tmp
RUN bash /tmp/prepare-build.sh

# Install Rust
ENV PATH=/root/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
RUN curl https://sh.rustup.rs -sqSf | \
sh -s -- -y --default-toolchain $RUST_TOOLCHAIN

WORKDIR /work

# TODO(tonyo): it can certainly be optimized
COPY . ./

RUN cargo build --target=$BUILD_TARGET --release --locked
RUN cp target/$BUILD_TARGET/release/semaphore /usr/local/bin/semaphore

# Copy the binary to a clean image
FROM ubuntu:14.04
RUN apt-get update \
&& apt-get install -y ca-certificates --no-install-recommends \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
COPY --from=0 /usr/local/bin/semaphore /bin/semaphore
WORKDIR /work
EXPOSE 3000
CMD ["/bin/semaphore"]

0 comments on commit 429de42

Please sign in to comment.