1
1
# Stage 1: Build the Rust application
2
- FROM rust:1.55 AS builder
2
+ FROM rust:latest AS builder
3
3
4
4
# Set the working directory
5
5
WORKDIR /usr/src/app
6
6
7
- # Copy Cargo.toml and Cargo.lock and install dependencies
8
- COPY Cargo.toml Cargo.lock ./
9
- RUN cargo fetch
7
+ # Copy the source code into the working directory
8
+ COPY . /usr/src/app/
9
+
10
+ # Copy the local dependencies
11
+ COPY ../entity /usr/src/entity
12
+ COPY ../entity_api /usr/src/entity_api
13
+ # COPY ../service /usr/src/service
10
14
11
- # Copy the rest of the code and build the application
12
- COPY . .
15
+ # Fetch the dependencies and build the application
16
+ RUN cargo build
17
+ RUN cargo fetch
13
18
RUN cargo build --release
14
19
15
20
@@ -25,16 +30,16 @@ LABEL description="The web service for the refactor platoform project."
25
30
RUN apk add --no-cache ca-certificates
26
31
27
32
# Create a non-root user and group
28
- RUN addgroup -S appgroup && adduser -S refactoruser -G refactorgroup
33
+ RUN addgroup -S refactorgroup && adduser -S refactoruser -G refactorgroup
29
34
30
35
# Set the working directory
31
36
WORKDIR /app
32
37
33
38
# Copy the binary from the build stage to the working directory
34
- COPY --from=builer /usr/src/app/target/release/app .
39
+ COPY --from=builder /usr/src/app/target/release/web .
35
40
36
41
# Change ownership of the binary to the non-root user
37
- RUN chown refactoruser:refactorgroup /app/app
42
+ RUN chown refactoruser:refactorgroup /app/web
38
43
39
44
# Expose the port that the app listens on
40
45
EXPOSE 8000
@@ -43,4 +48,4 @@ EXPOSE 8000
43
48
USER refactoruser
44
49
45
50
# Set the command to run the application
46
- CMD ["./app " ]
51
+ CMD ["./web " ]
0 commit comments