-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
32 lines (22 loc) · 797 Bytes
/
Dockerfile
File metadata and controls
32 lines (22 loc) · 797 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# Use Go v1.25.6 as the base image
FROM golang:1.25.6-alpine
RUN apk add --no-cache curl
# Create a new user in the docker image
RUN adduser --disabled-password --gecos '' gouser
# Create a new directory for goserve files and set the path in the container
RUN mkdir -p /home/gouser/goserve
# Set the working directory in the container
WORKDIR /home/gouser/goserve
# Copy the project files into the container
COPY . .
# Set the ownership of the goserve directory to gouser
RUN chown -R gouser:gouser /home/gouser/goserve
# Switch to the gouser user
USER gouser
# Download dependencies and build the project
RUN go mod tidy
RUN go build -o build/server cmd/main.go
# Expose the server port (replace 8080 with your actual port)
EXPOSE 8080
# Command to run the server
CMD ["./build/server"]