-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
52 lines (35 loc) · 1.09 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
47
48
49
50
51
52
# Step 1: Build the Next.js frontend
FROM node:18 as frontend
WORKDIR /app
# Copy the entire application code
COPY ui .
RUN yarn install
# Build the Next.js application and output to the "build" directory
RUN yarn build
FROM golang:1.21.3 as builder
# Set the working directory to /go/src/app
WORKDIR /go/src/app
# Copy the local package files to the container's workspace
COPY server .
# Copy the "build" directory from the frontend build
COPY --from=frontend /app/build ./cmd/server/public
# Set environment variables
ENV CGO_ENABLED=0
ENV GOOS=linux
ENV GOARCH=amd64
# Build the Go application
RUN go build -o petJournal ./cmd/server
# Start a new stage to reduce the final image size
FROM alpine:latest
# Set the working directory to /app
WORKDIR /app
# Copy the binary from the builder stage to the final stage
COPY --from=builder /go/src/app/petJournal .
# Set environment variable for your application
ENV SECRET_KEY=$SECRET_KEY
ENV DB_URL=$DB_URL
ENV DB_NAME=$DB_NAME
# Expose port 8080 for the application
EXPOSE 8080
# Define the command to run the application
ENTRYPOINT ["./petJournal"]