-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
57 lines (41 loc) · 1.59 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
################
##### Builder
FROM rust:slim-bullseye AS builder
ENV PROJECT /usr/src/rumgap
WORKDIR /usr/src
# Create blank project
RUN USER=root cargo new rumgap && cargo new rumgap/entity --lib && cargo new rumgap/migration --lib
# We want dependencies cached, so copy those first.
COPY Cargo.toml Cargo.lock build.rs icon.ico ${PROJECT}/
COPY entity/Cargo.toml ${PROJECT}/entity/
COPY migration/Cargo.toml ${PROJECT}/migration/
COPY proto ${PROJECT}/proto/
COPY entity/src ${PROJECT}/entity/src/
COPY migration/src ${PROJECT}/migration/src/
# Set the working directory
WORKDIR ${PROJECT}/
# Install build dependencies
RUN apt-get update && apt-get install -y pkg-config libssl-dev openssl protobuf-compiler && apt-get clean
# This is a dummy build to get the dependencies cached.
RUN cargo build --release
# Now copy in the rest of the sources
COPY src ${PROJECT}/src/
## Touch main.rs to prevent cached release build
RUN touch ${PROJECT}/src/main.rs
# This is the actual application build.
RUN cargo build --release
################
##### Runtime
FROM debian:bullseye AS runtime
# Copy application binary from builder image
COPY --from=builder /usr/src/rumgap/target/release/rumgap /usr/local/bin
COPY log4rs.yml /usr/local/bin
COPY configs /usr/local/bin/configs
RUN apt-get update && apt-get install -y ca-certificates openssl libssl-dev && apt-get clean
ENV HOST 0.0.0.0
ENV PORT 80
ENV DATABASE_URL "postgres://postgres:postgres@postgres/postgres"
ENV MANGA_UPDATE_INTERVAL_MS 600000
EXPOSE $PORT
# Run the application
CMD ["/usr/local/bin/rumgap"]