-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
59 lines (38 loc) · 1.13 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
48
49
50
51
52
53
54
55
56
57
58
59
FROM rust:1.72-slim-buster as builder
WORKDIR /
RUN apt-get update && \
apt-get install -y protobuf-compiler && \
USER=root cargo new --bin rustest
WORKDIR /rustest
COPY ./Cargo.* ./
RUN rm -rf .git* && \
cargo build --release && \
rm -rf ./src
COPY ./src ./src
RUN rm ./target/release/deps/rustest-* && \
cargo build --release
###############################################################
FROM node:18.18.2-alpine as front_builder
WORKDIR /front
COPY ./front/package*.json ./
RUN npm install
COPY ./front/src ./src/
COPY ./front/public ./public
RUN npm run build
################################################################
FROM debian:buster-slim
ARG APP=/usr/src/app
RUN apt-get update \
&& apt-get install -y ca-certificates tzdata \
&& rm -rf /var/lib/apt/lists/*
ENV TZ=Etc/UTC \
APP_USER=appuser
RUN groupadd $APP_USER \
&& useradd -g $APP_USER $APP_USER \
&& mkdir -p ${APP}
COPY --from=builder /rustest/target/release/rustest ${APP}/rustest
COPY --from=front_builder /front/ ${APP}/front
# RUN chown -R $APP_USER:$APP_USER ${APP}
# USER $APP_USER
WORKDIR ${APP}
CMD ["./rustest"]