-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
86 lines (59 loc) · 1.94 KB
/
Copy pathDockerfile
File metadata and controls
86 lines (59 loc) · 1.94 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# Build stage for development environment
FROM golang:1.26.5-alpine AS dev
# Add Maintainer info
LABEL maintainer="Hunter Tratar"
# Setup folders
RUN mkdir /app
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
RUN apk add --no-cache make gcc libc-dev git
# Setup hot-reload for dev stage
RUN go install -mod=mod github.com/githubnemo/CompileDaemon
RUN go get -v golang.org/x/tools/gopls
RUN go install github.com/pressly/goose/v3/cmd/goose@latest
RUN go install gotest.tools/gotestsum@latest
COPY Makefile .
ENV PATH=$PATH:/root/go/bin
# Entry point for dev environment
ENTRYPOINT CompileDaemon --build="make build" --command="./bin/api -smtp-host=localhost -smtp-port=1025 -smtp-username= -smtp-password= -metrics=true"
# Build stage for frontend
FROM node:alpine AS frontend
# Setup folders
WORKDIR /app/frontend
# Install dependencies
COPY frontend/package*.json ./
RUN npm ci
# Build the frontend
COPY frontend/ .
RUN npm run build
# Build stage for production environment
FROM golang:alpine AS prod
# Add Maintainer info
LABEL maintainer="Hunter Tratar"
# Setup folders
RUN mkdir /app
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
RUN go install github.com/pressly/goose/v3/cmd/goose@latest
# Install necessary build tools for production
RUN apk add --no-cache make gcc libc-dev git
# Copy the source code and build the application
COPY . .
# Copy the built frontend dist from the frontend stage
COPY --from=frontend /app/frontend/dist ./frontend/dist
# Build the application in production
RUN make build
# Final image for production, copying over the built binary
FROM alpine:latest
# Setup the app folder
WORKDIR /app
# Copy the compiled binary from the prod build stage
COPY --from=prod /app/bin/linux/_amd64/api /app/bin/
# Expose the production app port
EXPOSE 3000
# Ensure the binary is executable
RUN chmod +x /app/bin/api
# Command to run the production application
ENTRYPOINT ["/app/bin/api", "-metrics=true", "-env=production"]