-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
46 lines (32 loc) · 1.13 KB
/
Dockerfile
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# Use the official Golang image as the build stage
FROM golang:1.23 AS builder
# Set the working directory inside the container
WORKDIR /app
# Copy the go.mod and go.sum files
COPY go.mod go.sum ./
# Download the Go module dependencies
RUN go mod download
# Copy the rest of the application code
COPY . .
# Build the Go application
RUN go build -ldflags "-s -w" -o main .
# Use the official Golang image as the base image for the final stage
FROM golang:1.23
# Install necessary runtime dependencies
RUN apt-get update && apt-get install -y gettext-base && rm -rf /var/lib/apt/lists/*
# Set the working directory inside the container
WORKDIR /app
# Copy the built Go application from the builder stage
COPY --from=builder /app/main .
COPY config.template.json /app/config.template.json
COPY init-config.sh /app/init-config.sh
# Copy the views directory
COPY views /app/views
# Copy the static directory
COPY public /app/public
# Make the initialization script executable
RUN chmod +x /app/init-config.sh
# Expose the port on which the application will run
EXPOSE 3000
# Command to run the initialization script
CMD ["/app/init-config.sh"]