Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add Dockerfile #23

Merged
merged 1 commit into from
May 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
feat: Add Dockerfile
  • Loading branch information
tonyo committed May 15, 2018
commit 1eb9d7ea6ed126f96e41744d9727a6c879695700
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"]