-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
58 lines (40 loc) · 1.22 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
# Use Node base image to compile css with tailwind
FROM node:18 as styler
# Set the working directory in the container
WORKDIR /usr/src/app
# Copy js stuff
COPY tailwind.config.js package.json yarn.lock ./
COPY templates/input.css ./templates/input.css
# Compile and minify css
RUN yarn install
RUN yarn prod
# Use a Rust base image
FROM rust:latest as builder
# Set the working directory in the container
WORKDIR /usr/src/app
# Copy the Cargo.toml and Cargo.lock files to the container
COPY Cargo.toml Cargo.lock ./
# Copy the source code to the container
COPY src ./src
# Copy templates
COPY templates ./templates
# DB migrations
COPY migrations ./migrations
# Build the Rust project
RUN cargo build --release
# Create a smaller release image
FROM debian:buster-slim
# Set the working directory in the container
WORKDIR /usr/src/app
# Copy css from styler
COPY --from=styler /usr/src/app/assets/output.css ./assets/output.css
# Copy the built executable from the builder stage to the final image
COPY --from=builder /usr/src/app/target/release/webrs ./
# Copy articles to migrate
COPY articles ./articles
# Copy templates
COPY templates ./templates
# Copy assets such as favicon
COPY assets ./assets
# Run the binary
CMD ["./webrs"]