Browse Source

Updated dockerfile

merge-requests/1/head
Victor Roest 2 years ago
parent
commit
f0ab2def76
Signed by: 0x76 GPG Key ID: F69440FC85CD66CD
  1. 981
      Cargo.lock
  2. 45
      Dockerfile

981
Cargo.lock

File diff suppressed because it is too large

45
Dockerfile

@ -1,28 +1,33 @@
# -*- mode: dockerfile -*-
ARG BASE_IMAGE=ekidd/rust-musl-builder:latest
# ------------------------------------------------------------------------------
# Cargo Build Stage
# ------------------------------------------------------------------------------
# Our first FROM statement declares the build environment.
FROM ${BASE_IMAGE} AS builder
FROM rust:latest as cargo-build
# Cache our dependencies
WORKDIR /home/rust/
RUN USER=rust cargo new xkcd --bin
WORKDIR /home/rust/xkcd
COPY Cargo.* ./
RUN cargo build --release && rm ./target/x86_64-unknown-linux-musl/release/deps/xkcd* && rm -rf ./src/
WORKDIR /usr/src/xkcd
# Add our source code.
COPY . ./
COPY Cargo.toml Cargo.toml
# Fix permissions on source code.
RUN sudo chown -R rust:rust /home/rust
RUN mkdir src/
RUN echo "fn main() {println!(\"if you see this, the build broke\")}" > src/main.rs
RUN cargo build --release
RUN rm -f target/release/deps/xkcd*
COPY src src
# Build our application.
RUN cargo build --release
# Runner
FROM alpine:latest
RUN apk --no-cache add ca-certificates
COPY --from=builder /home/rust/xkcd/target/x86_64-unknown-linux-musl/release/xkcd /xkcd
# ------------------------------------------------------------------------------
# Final Stage
# ------------------------------------------------------------------------------
FROM debian:stable-slim
RUN apt-get update && apt-get install ca-certificates -y
COPY --from=cargo-build /usr/src/xkcd/target/release/xkcd .
CMD /xkcd
CMD ["./xkcd"]

Loading…
Cancel
Save