-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
65 lines (48 loc) · 1.7 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
60
61
62
63
64
65
FROM rust:1.45 as server-builder
RUN USER=root cargo new --bin zakar_server
WORKDIR /zakar_server
COPY ./zakar_server/Cargo.toml ./Cargo.toml
COPY ./zakar_server/Cargo.lock ./Cargo.lock
COPY ./zakar_server/diesel.toml ./diesel.toml
COPY ./zakar_server/migrations ./migrations
RUN cargo install diesel_cli --no-default-features --features postgres
RUN mkdir -p /out && cp /usr/local/cargo/bin/diesel /out/
RUN cargo build --release
RUN rm src/*.rs
COPY ./zakar_server ./
RUN rm ./target/release/deps/zakar_server*
RUN cargo build --release
FROM node as client-builder
WORKDIR /app
COPY ./zakar-client/package.json ./
COPY ./zakar-client/yarn.lock ./
RUN yarn
COPY ./zakar-client ./
RUN yarn build
FROM debian:buster-slim
ARG APP=/usr/src/app
RUN apt-get update \
&& apt-get -y install libpq-dev \
&& apt-get install -y ca-certificates tzdata \
&& rm -rf /var/lib/apt/lists/*
EXPOSE 8000
ENV TZ=Etc/UTC \
APP_USER=appuser
RUN groupadd $APP_USER \
&& useradd -g $APP_USER $APP_USER \
&& mkdir -p ${APP} \
&& mkdir -p /usr/src/zakar-client/build
COPY --from=client-builder /app/build /usr/src/zakar-client/build/
COPY --from=server-builder /zakar_server/target/release/zakar_server ${APP}/zakar_server
COPY --from=server-builder /zakar_server/diesel.toml ${APP}/
COPY --from=server-builder /zakar_server/Cargo.toml ${APP}/
COPY --from=server-builder /zakar_server/Cargo.lock ${APP}/
COPY --from=server-builder /zakar_server/migrations ${APP}/migrations/
COPY --from=server-builder /out/diesel /bin/
COPY ./deployment-tasks.sh ${APP}/
COPY ./Dockerfile ${APP}/
RUN chown -R $APP_USER:$APP_USER ${APP}
WORKDIR ${APP}
RUN chmod +x ./deployment-tasks.sh
USER $APP_USER
CMD ["./deployment-tasks.sh"]