[#17] Wrote dockerfiles; moved everything to Docker
This commit is contained in:
parent
7243be302c
commit
93ec27bb02
6 changed files with 112 additions and 63 deletions
19
docker/Dockerfile.builder
Normal file
19
docker/Dockerfile.builder
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
# We use a multi-stage build to end up with a very small final image
|
||||
FROM alpine:latest AS builder
|
||||
|
||||
ARG MODE
|
||||
ARG RUN_TESTS
|
||||
|
||||
ENV PATH "$PATH:/root/.cargo/bin"
|
||||
# Needed for proper compiling of openssl-dev
|
||||
ENV RUSTFLAGS="-C target-feature=-crt-static"
|
||||
|
||||
WORKDIR /usr/src/app
|
||||
|
||||
# Install build dependencies, rustup & rust's nightly build & toolchain
|
||||
RUN apk update && apk add --no-cache openssl-dev build-base curl && \
|
||||
{ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain nightly; }
|
||||
|
||||
# Copy source code over to builder
|
||||
COPY Cargo.toml Cargo.lock ./
|
||||
COPY src/ ./src/
|
||||
6
docker/Dockerfile.dev
Normal file
6
docker/Dockerfile.dev
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
FROM chewingbever/fej-builder:latest
|
||||
|
||||
ENV RUST_BACKTRACE=1
|
||||
|
||||
ENTRYPOINT ["cargo"]
|
||||
CMD ["run"]
|
||||
22
docker/Dockerfile.rel
Normal file
22
docker/Dockerfile.rel
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
FROM chewingbever/fej-builder:latest AS builder
|
||||
|
||||
# And then finally, build the project
|
||||
# Thank the lords that this article exists
|
||||
# https://users.rust-lang.org/t/sigsegv-with-program-linked-against-openssl-in-an-alpine-container/52172
|
||||
# TODO add what these flags do & why they work
|
||||
# NOTE: cargo install auto-appends bin to the path
|
||||
RUN --mount=type=cache,target=/usr/src/app/target \
|
||||
--mount=type=cache,target=/root/.cargo/registry \
|
||||
cargo install --path . --bin fej --root /usr/local
|
||||
|
||||
|
||||
# Now, we create the actual image
|
||||
FROM alpine:latest
|
||||
|
||||
# Install some dynamic libraries needed for everything to work
|
||||
RUN apk update && apk add --no-cache openssl libgcc
|
||||
|
||||
# Copy binary over to final image
|
||||
COPY --from=builder /usr/local/bin/fej /usr/local/bin/fej
|
||||
|
||||
CMD ["/usr/local/bin/fej"]
|
||||
Reference in a new issue