feat(ci): make executable static and make final image be from scratch to make container as small as possible
This commit is contained in:
parent
325fa15437
commit
3b7881a496
2 changed files with 7 additions and 8 deletions
|
|
@ -1,2 +1,2 @@
|
|||
[target.'cfg(target_arch = "x86_64")']
|
||||
rustflags = ["-C", "target-feature=+aes,+sse2,-crt-static"]
|
||||
rustflags = ["-C", "target-feature=+aes,+sse2"]
|
||||
13
Dockerfile
13
Dockerfile
|
|
@ -1,25 +1,24 @@
|
|||
FROM rust:alpine as builder
|
||||
|
||||
RUN apk add --no-cache musl-dev openssl-dev musl openssl libcrypto3
|
||||
RUN apk add --no-cache musl-dev openssl-dev openssl-libs-static protobuf-dev lld
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY . .
|
||||
|
||||
RUN cargo build --profile prod
|
||||
RUN OPENSSL_LIB_DIR=/usr/lib OPENSSL_INCLUDE_DIR=/usr/include/openssl OPENSSL_STATIC=1 RUSTFLAGS="-C target-feature=+aes,+sse -C relocation-model=static -C linker=ld.lld" cargo build --profile prod --target x86_64-unknown-linux-musl
|
||||
|
||||
RUN rm .env
|
||||
|
||||
FROM rust:alpine AS final
|
||||
FROM scratch AS final
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy the compiled binary from the builder stage
|
||||
COPY --from=builder /app/target/prod/account /app/account
|
||||
COPY --from=builder /app/target/x86_64-unknown-linux-musl/prod/account /account
|
||||
|
||||
# Set executable permissions
|
||||
RUN chmod +x /app/account
|
||||
# RUN chmod +x /account
|
||||
|
||||
# Command to run the application
|
||||
CMD ["ls /app"]
|
||||
CMD ["/app/account"]
|
||||
ENTRYPOINT ["/account"]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue