|
1 | | -# Import Background Image |
| 1 | +# Import Basic Image. |
2 | 2 | FROM rust:latest as build |
3 | 3 |
|
4 | | -# Set up work path |
| 4 | +# Set up work path. |
5 | 5 | WORKDIR /home/app |
6 | 6 |
|
7 | | -# Copy the Rust Project Files to Docker Image |
| 7 | +# Copy the Rust Project Files to Docker Image. |
| 8 | +# | Please pay attention to the COPY command, which is defined in Docker docs as follows: |
| 9 | +# | `Note: The directory itself is not copied, just its contents.` |
| 10 | +# | URL: https://docs.docker.com/engine/reference/builder/ |
8 | 11 | COPY ./Cargo.toml /home/app |
9 | | -COPY ./src /home/app |
| 12 | +COPY ./src /home/app/src |
| 13 | +COPY ./build.rs /home/app |
10 | 14 |
|
11 | | -# Set up Target Environment variable |
| 15 | +# Set up Target Environment variable. |
12 | 16 | ENV OUT_DIR /home/app/target |
13 | 17 |
|
14 | | -# Cargo build Rust Project |
| 18 | +# Cargo build Rust Project. |
15 | 19 | RUN cargo build --release |
16 | 20 |
|
17 | | -# Build a production environment Docker Image |
| 21 | +# Build a production environment Docker Image. |
18 | 22 | FROM ubuntu:22.04 |
19 | 23 | LABEL author="Snowball_233" |
20 | 24 |
|
21 | | -# Switch to Root account |
| 25 | +# Switch to Root account. |
22 | 26 | USER root |
23 | 27 |
|
24 | | -# Ubuntu Initialization |
| 28 | +# Ubuntu Initialization. |
| 29 | +# | Please replace the time zone according to your needs. |
25 | 30 | RUN \ |
26 | 31 | ln -snf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \ |
27 | 32 | echo 'Asia/Shanghai' > /etc/timezone && \ |
28 | 33 | apt-get update && \ |
29 | 34 | apt-get -y upgrade && \ |
30 | 35 | apt-get install -y htop vim |
31 | 36 |
|
32 | | -# Copy the binary files into Docker Image |
33 | | -# Please replace the specific path according to your needs |
| 37 | +# Copy the binary files into Docker Image. |
| 38 | +# | Please replace the specific path according to your needs. |
34 | 39 | COPY --from=build /home/app/target/release /home/BackendServer |
35 | 40 |
|
36 | | -# Clean up build cache |
| 41 | +# Clean up build cache. |
37 | 42 | RUN \ |
38 | 43 | apt-get clean && \ |
39 | 44 | apt-get autoclean && \ |
40 | 45 | rm -rf /var/lib/apt/lists/* |
41 | 46 |
|
| 47 | +# Run bash on start. |
42 | 48 | CMD ["bash"] |
0 commit comments