From b6c0b855fd25d0f5c0558b0462aac559136074bc Mon Sep 17 00:00:00 2001 From: Snowball_233 Date: Thu, 31 Aug 2023 01:05:26 +0800 Subject: [PATCH] ci&doc: fix the file path issues and write key comments --- Dockerfile | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/Dockerfile b/Dockerfile index 776d92f..b7f3e0c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,27 +1,32 @@ -# Import Background Image +# Import Basic Image. FROM rust:latest as build -# Set up work path +# Set up work path. WORKDIR /home/app -# Copy the Rust Project Files to Docker Image +# Copy the Rust Project Files to Docker Image. +# | Please pay attention to the COPY command, which is defined in Docker docs as follows: +# | `Note: The directory itself is not copied, just its contents.` +# | URL: https://docs.docker.com/engine/reference/builder/ COPY ./Cargo.toml /home/app -COPY ./src /home/app +COPY ./src /home/app/src +COPY ./build.rs /home/app -# Set up Target Environment variable +# Set up Target Environment variable. ENV OUT_DIR /home/app/target -# Cargo build Rust Project +# Cargo build Rust Project. RUN cargo build --release -# Build a production environment Docker Image +# Build a production environment Docker Image. FROM ubuntu:22.04 LABEL author="Snowball_233" -# Switch to Root account +# Switch to Root account. USER root -# Ubuntu Initialization +# Ubuntu Initialization. +# | Please replace the time zone according to your needs. RUN \ ln -snf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \ echo 'Asia/Shanghai' > /etc/timezone && \ @@ -29,14 +34,15 @@ RUN \ apt-get -y upgrade && \ apt-get install -y htop vim -# Copy the binary files into Docker Image -# Please replace the specific path according to your needs +# Copy the binary files into Docker Image. +# | Please replace the specific path according to your needs. COPY --from=build /home/app/target/release /home/BackendServer -# Clean up build cache +# Clean up build cache. RUN \ apt-get clean && \ apt-get autoclean && \ rm -rf /var/lib/apt/lists/* +# Run bash on start. CMD ["bash"]