Skip to content

Commit

Permalink
fix: modify dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
RRRHAN committed Mar 16, 2024
1 parent 1aa462c commit 221c2a0
Showing 1 changed file with 13 additions and 22 deletions.
35 changes: 13 additions & 22 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,32 +1,23 @@
# Use the official Golang image
FROM golang:1.20-alpine as builder
# Use the official Golang image as the base image
FROM golang:latest

# Set the working directory to /app
# Set the working directory inside the container
WORKDIR /app

# Copy the Go modules files
COPY go.mod go.sum ./
# Copy the go.mod and go.sum files to the container
COPY ./back-end/go.mod ./back-end/go.sum ./

# Download dependencies
# Download the dependencies
RUN go mod download

# Copy the source code into the container
COPY . .
# Copy the rest of the source code from the host to the container
COPY ./back-end ./

# Build the Go app
RUN CGO_ENABLED=0 GOOS=linux go build -o app .
RUN go build -o main .

# Final image
FROM alpine:latest
# Expose the port the app runs on
EXPOSE 8080

# Set the working directory to /root
WORKDIR /root/

# Copy the binary from the builder stage
COPY --from=builder /app/app .

# Expose port 9999
EXPOSE 9999

# Command to run the app
CMD ["./app"]
# Command to run the executable
CMD ["./main"]

0 comments on commit 221c2a0

Please sign in to comment.