2025-03-08 00:53:11 +01:00
|
|
|
# syntax=docker/dockerfile:1
|
|
|
|
|
|
2025-03-06 18:43:38 +01:00
|
|
|
FROM rust:alpine as builder
|
|
|
|
|
|
2025-03-07 17:19:47 +01:00
|
|
|
RUN apk add --no-cache musl-dev openssl-dev openssl-libs-static protobuf-dev lld
|
2025-03-05 23:20:11 +01:00
|
|
|
|
|
|
|
|
WORKDIR /app
|
|
|
|
|
|
2025-05-08 08:19:45 +00:00
|
|
|
# this optimizes build time by putting the dependencies in a seperate docker layer, speeding up future builds
|
2025-05-08 08:25:34 +00:00
|
|
|
COPY Cargo.toml Cargo.lock ./
|
2025-05-08 08:24:24 +00:00
|
|
|
COPY mii ./mii
|
2025-05-08 08:19:45 +00:00
|
|
|
RUN mkdir src && echo "fn main() {}" > src/main.rs && cargo fetch
|
|
|
|
|
|
2025-03-05 23:20:11 +01:00
|
|
|
COPY . .
|
|
|
|
|
|
2025-11-03 07:25:19 +00:00
|
|
|
ENV SQLX_OFFLINE=true
|
2025-03-05 23:20:11 +01:00
|
|
|
|
2025-11-03 07:25:19 +00:00
|
|
|
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
|
2025-03-06 11:36:21 +00:00
|
|
|
|
2025-03-07 17:19:47 +01:00
|
|
|
FROM scratch AS final
|
2025-03-05 23:20:11 +01:00
|
|
|
|
2025-11-04 22:23:24 +01:00
|
|
|
WORKDIR /
|
2025-03-05 23:20:11 +01:00
|
|
|
|
|
|
|
|
# Copy the compiled binary from the builder stage
|
2025-03-07 17:19:47 +01:00
|
|
|
COPY --from=builder /app/target/x86_64-unknown-linux-musl/prod/account /account
|
2025-11-04 22:23:24 +01:00
|
|
|
COPY --from=builder /app/res /res
|
2025-03-05 23:20:11 +01:00
|
|
|
|
|
|
|
|
# Set executable permissions
|
2025-03-07 17:19:47 +01:00
|
|
|
# RUN chmod +x /account
|
2025-03-05 23:20:11 +01:00
|
|
|
|
|
|
|
|
# Command to run the application
|
2025-03-07 17:19:47 +01:00
|
|
|
ENTRYPOINT ["/account"]
|