-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile_alpine
53 lines (38 loc) · 1.36 KB
/
Dockerfile_alpine
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
48
49
50
51
52
53
################
##### Builder
FROM rust:1.69-alpine3.17 as builder
RUN apk add git curl
RUN apk add pkgconfig openssl-dev gcc musl-dev rustup
RUN rustup-init -t x86_64-unknown-linux-musl --default-toolchain nightly --profile minimal -y
RUN git clone https://github.com/sfackler/rust-openssl /build
RUN cd /build && cargo build --release && cd ..
ADD --chown=rust:rust ./Cargo.toml ./
RUN mkdir -p ./src && touch ./src/main.rs && cargo fetch
ADD --chown=rust:rust ./src ./src
# This is a dummy build to get the dependencies cached.
RUN cargo build --target x86_64-unknown-linux-musl --release
################
##### Runtime
FROM alpine:3 AS runtime
ARG UID=1001
ARG USER=app
ARG GID=1001
ARG GROUP=app
ENV WORKINGDIR /app
EXPOSE 8080
RUN apk --no-cache add ca-certificates openssl
WORKDIR $WORKINGDIR
RUN addgroup -g $GID -S $GROUP && adduser -u $UID -S $USER -G $GROUP && \
mkdir -p /app &&\
chown -R $USER:$GROUP /app
# Copy application binary from builder image
#COPY --from=builder /build/target/x86_64-unknown-linux-musl/release/* /app/ssl
COPY --from=builder /target/x86_64-unknown-linux-musl/release/kostal-plenticore-rs /app
RUN ln -s /usr/lib/libcrypto.so.1.1 /usr/lib/libcrypto.so.3
RUN ln -s /usr/lib/libssl.so.1.1 /usr/lib/libssl.so.3
USER $USER
ENV RUST_LOG=info
ENV ROCKET_PORT=8080
ENV ROCKET_ADDRESS=0.0.0.0
# Run the application
CMD ./kostal-plenticore-rs