-
Notifications
You must be signed in to change notification settings - Fork 4
/
Dockerfile
47 lines (38 loc) · 1.4 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
ARG BUILD_FLAGS=
ARG BUILD_TARGET=debug
## Base image with Rust toolchain and dependencies
FROM buildpack-deps:24.04-curl AS base
LABEL maintainer="Laurent Wouters <lwouters@cenotelie.fr>" vendor="Cénotélie Opérations SAS" description="Cratery -- a private cargo registry"
# add packages
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
pkg-config \
libsqlite3-0 \
libsqlite3-dev \
musl-tools \
git \
ssh
# add custom user
RUN groupmod -n cratery ubuntu && usermod -l cratery -d /home/cratery ubuntu && mv /home/ubuntu /home/cratery
ENV HOME=/home/cratery
USER cratery
# Add support for Rust
ENV PATH="/home/cratery/.cargo/bin:${PATH}"
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y \
&& rustup toolchain install nightly \
&& rustup default nightly \
&& rm -rf /home/cratery/.cargo/registry \
&& mkdir /home/cratery/.cargo/registry
# add ssh host key for github.com
RUN mkdir /home/cratery/.ssh && ssh-keyscan -t rsa github.com >> /home/cratery/.ssh/known_hosts
RUN chmod -R go-rwx /home/cratery/.ssh
## Builder to build the application
FROM base AS builder
ARG BUILD_FLAGS
COPY --chown=cratery . /home/cratery/src
RUN cd /home/cratery/src && cargo +stable build ${BUILD_FLAGS}
## Final target from the base with the application's binary
FROM base
ARG BUILD_TARGET
COPY --from=builder /home/cratery/src/target/${BUILD_TARGET}/cratery /
ENTRYPOINT ["/cratery"]