Skip to content

Commit

Permalink
Refactor Dockerfile for multi-stage build
Browse files Browse the repository at this point in the history
  • Loading branch information
geraldwuhoo committed Feb 9, 2022
1 parent ddb3ff4 commit 0a4fc30
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
1 change: 1 addition & 0 deletions tools/docker/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Dockerfile
14 changes: 10 additions & 4 deletions tools/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
FROM rust:alpine AS builder
RUN wget -O source.tar.gz $(wget -qO- https://api.github.com/repos/mbrubeck/agate/releases/latest | sed -nE 's/^.*"tarball_url"\s*:\s*"([^"]+)".*$/\1/p')&& tar xzf source.tar.gz && \
mv mbrubeck-agate-* /agate

WORKDIR /agate
RUN apk --no-cache add libc-dev && \
cargo install --target x86_64-unknown-linux-musl --path .

FROM alpine:latest
RUN apk add cargo && wget -O source.tar.gz $(wget -qO- https://api.github.com/repos/mbrubeck/agate/releases/latest | sed -nE 's/^.*"tarball_url"\s*:\s*"([^"]+)".*$/\1/p')&& tar xzf source.tar.gz && mv /mbrubeck-agate-* /agate && cd agate && cargo build --release
RUN cp /agate/target/release/agate /usr/bin/agate
COPY --from=builder /usr/local/cargo/bin/agate /usr/bin/agate
WORKDIR /app
COPY . /app
ADD . .
COPY start.sh /app
ENTRYPOINT ["/bin/sh", "start.sh"]

0 comments on commit 0a4fc30

Please sign in to comment.