-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
42 lines (30 loc) · 1 KB
/
Dockerfile
File metadata and controls
42 lines (30 loc) · 1 KB
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
# Stage 1: Build the Go application
FROM golang:1.21 AS builder
# Set the working directory for the Go application
WORKDIR /app
# Copy go module files and download dependencies
COPY go.mod go.sum ./
RUN go mod download
# Copy the rest of the Go application code except web/ directory
COPY backend ./backend
# Build the Go application
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o /app/server ./backend
# Stage 2: Setup Node.js environment and combine both applications
FROM node:20-alpine
# Set the working directory for the combined application
WORKDIR /app
# Copy the Node.js application code
COPY web/ ./web
RUN npm install --prefix ./web/front
# Copy the built Go server binary from the first stage
COPY --from=builder /app/server ./server
# Copy the start script and ensure it is executable
COPY start.sh ./start.sh
RUN chmod +x ./server ./start.sh
# Copy the rest of the frontend code
COPY credentials.json ./
# Expose ports
EXPOSE 8080
EXPOSE 80
# Set the CMD to run the script
CMD ["./start.sh"]