Skip to content

Commit 68f9029

Browse files
committed
enhancement: adds web Dockerfile
1 parent 95b22df commit 68f9029

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

web/Dockerfile

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
11
# Stage 1: Build the Rust application
2-
FROM rust:1.55 AS builder
2+
FROM rust:latest AS builder
33

44
# Set the working directory
55
WORKDIR /usr/src/app
66

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
1014

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
1318
RUN cargo build --release
1419

1520

@@ -25,16 +30,16 @@ LABEL description="The web service for the refactor platoform project."
2530
RUN apk add --no-cache ca-certificates
2631

2732
# 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
2934

3035
# Set the working directory
3136
WORKDIR /app
3237

3338
# 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 .
3540

3641
# Change ownership of the binary to the non-root user
37-
RUN chown refactoruser:refactorgroup /app/app
42+
RUN chown refactoruser:refactorgroup /app/web
3843

3944
# Expose the port that the app listens on
4045
EXPOSE 8000
@@ -43,4 +48,4 @@ EXPOSE 8000
4348
USER refactoruser
4449

4550
# Set the command to run the application
46-
CMD ["./app"]
51+
CMD ["./web"]

0 commit comments

Comments
 (0)