From 429de4231d33919147780ffe690bb9ed5ae1c76b Mon Sep 17 00:00:00 2001 From: Anton Ovchinnikov Date: Tue, 15 May 2018 17:59:26 +0200 Subject: [PATCH] feat: Add Dockerfile (#23) --- .dockerignore | 10 ++++++++++ Dockerfile | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000000..6f7f2e8ffd --- /dev/null +++ b/.dockerignore @@ -0,0 +1,10 @@ +.dockerignore +.git +.vscode +.*.swp +.travis* +*.pyc +target/ +cabi/target +Dockerfile +py/venv diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000..6d4506fa6d --- /dev/null +++ b/Dockerfile @@ -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"]