1
Fork 0
ci-images/images/gitea/Dockerfile

40 lines
1.1 KiB
Docker

FROM rust:alpine AS builder
# Use a dummy project to ensure the crate index is up to date.
RUN set -e; \
cargo new --color always /tmp/dummy; \
cargo add --color always --manifest-path /tmp/dummy/Cargo.toml serde; \
rm -rf /tmp/dummy; \
cargo new --color always --bin /app
WORKDIR /app
RUN apk add --no-cache \
# openssl-dev \
# pkgconfig \
musl-dev
# Build dependencies with a dummy project to cache those regardless of changes
# in the actual source code
COPY ./Cargo.toml ./Cargo.lock /app/
RUN cargo build --color always --release --locked
COPY . .
RUN touch -a -m ./src/main.rs && cargo build --color always --release --locked
FROM alpine AS final
RUN apk add --no-cache ca-certificates
ENV RUST_BACKTRACE=1
ENV RUST_LOG=info
COPY --from=builder /app/target/release/gitea /bin/
# Put this last, as it's the only thing that's different between variants.
# This way, the previous layers can all be shared.
ARG VARIANT="missing build arg 'VARIANT'"
ARG VERSION="0.1.0"
LABEL version="$VERSION"
COPY ./shims/${VARIANT}/* /opt/resource/