Skip to content

Commit

Permalink
feat: Update Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
Vann-Dev committed Apr 17, 2024
1 parent 4a85d37 commit cb0124f
Showing 1 changed file with 30 additions and 4 deletions.
34 changes: 30 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,39 @@
FROM rust:1.77.2 as build

WORKDIR /image-proxy
RUN apt-get update

RUN apt-get install musl-tools -y

RUN rustup target add x86_64-unknown-linux-musl

WORKDIR /usr/src/image-proxy

COPY Cargo.toml Cargo.toml

RUN mkdir src/

RUN echo "fn main() {println!(\"if you see this, the build broke\")}" > src/main.rs

RUN RUSTFLAGS=-Clinker=musl-gcc cargo build --release --target=x86_64-unknown-linux-musl

RUN rm -f target/x86_64-unknown-linux-musl/release/deps/image-proxy*

COPY . .

RUN cargo build --release
RUN RUSTFLAGS=-Clinker=musl-gcc cargo build --release --target=x86_64-unknown-linux-musl

FROM alpine:latest

RUN addgroup -g 1000 myapp

RUN adduser -D -s /bin/sh -u 1000 -G image-proxy myapp

WORKDIR /home/image-proxy/bin/

COPY --from=build /usr/src/image-proxy/target/x86_64-unknown-linux-musl/release/image-proxy .

FROM rust:1.77.2
RUN chown myapp:myapp image-proxy

COPY --from=build /image-proxy/target/release/image-proxy .
USER myapp

CMD ["./image-proxy"]

0 comments on commit cb0124f

Please sign in to comment.