-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
63 lines (45 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
60
61
62
63
FROM node:16 as frontend
WORKDIR frontend
# Install dependencies
COPY frontend/package.json .
COPY frontend/yarn.lock .
RUN yarn install
# Add project files
COPY frontend/index.html .
COPY frontend/public ./public
COPY frontend/src ./src
COPY frontend/tsconfig.json .
COPY frontend/tsconfig.node.json .
COPY frontend/vite.config.ts .
# Build project
RUN yarn build
FROM rust:1.62 as builder
RUN cargo new --bin davoxide
WORKDIR davoxide
# Install dependencies
COPY Cargo.toml .
COPY Cargo.lock .
RUN cargo build --release
# Add project files
COPY --from=frontend /frontend/dist ./frontend/dist
COPY build.rs .
COPY sqlx-data.json .
COPY migrations ./migrations
COPY src ./src
# Compile project
RUN rm ./target/release/davoxide*
RUN cargo build --release
FROM debian:11-slim
RUN apt-get update && \
apt-get install -y ca-certificates tzdata && \
rm -rf /var/lib/apt/lists/*
# Switch to non-root user
RUN adduser --disabled-password app
USER app
# Configure defaults
ENV ADDRESS 0.0.0.0:3000
ENV RUST_LOG info
ENV TZ Etc/UTC
EXPOSE 3000
COPY --from=builder --chown=app /davoxide/target/release/davoxide /davoxide
CMD ["./davoxide"]