-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
58 lines (44 loc) · 1.4 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
# Build layer
FROM rustlang/rust:nightly as builder
# Add LLVM project APT repository
RUN wget https://apt.llvm.org/llvm-snapshot.gpg.key
RUN apt-key add llvm-snapshot.gpg.key
RUN rm llvm-snapshot.gpg.key
# Install developement libraries and headers
RUN apt update -y
RUN apt install -y default-libmysqlclient-dev clang lldb lld
RUN apt clean -y
# Create a new empty shell project
RUN USER=root cargo new --bin discord_smp_link
WORKDIR /discord_smp_link/
COPY ./.cargo ./.cargo
# Copy over the manifests
COPY Cargo.toml Cargo.lock ./
# Build and cache your dependencies
RUN cargo build --release
RUN rm src/*.rs
# Copy the source
COPY ./src ./src
COPY ./migrations ./migrations
# Build for release
RUN rm ./target/release/deps/discord_smp_link*
RUN cargo build --release
# Run step
FROM debian:buster-slim as runtime
# Install dependencies
RUN apt update -y
RUN apt install -y default-libmysqlclient-dev libssl-dev ca-certificates
RUN rm -rf /var/lib/apt/lists/*
# Create a folder to recover logs and get .env file
WORKDIR /discord_smp_link/
# Copy the public content
COPY ./public ./public
COPY ./templates ./templates
COPY ./translations ./translations
COPY ./Rocket.toml ./
# Copy the build artifact from the build stage
COPY --from=builder /discord_smp_link/target/release/discord_smp_link ./discord_smp_link
# Expose the server port
EXPOSE 8000
# Set the startup command to run your binary
CMD ["./discord_smp_link"]