-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
58 lines (41 loc) · 1.22 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
53
54
55
56
57
58
# Stage 1: Builder Stage
FROM golang:1.22 AS builder
# Set the working directory inside the container
WORKDIR /app
# Copy the Go modules manifests
COPY go.mod go.sum ./
# Download Go modules
RUN go mod download
# Copy the source code
COPY . .
# Build the Go application with CGO disabled and list files for debugging
RUN CGO_ENABLED=0 GOOS=linux go build -o app ./cmd/api && ls -l /app
# Stage 2: Final Image
FROM alpine:latest
# Set the working directory inside the container
WORKDIR /root/
# Copy the binary from the builder stage
COPY --from=builder /app/app .
# Ensure the binary is executable
RUN chmod +x ./app
# Copy the .env file
COPY .env .
# List files in the final image for debugging
RUN ls -l /root
# Copy the migration files
COPY ./migrations ./migrations
# Copy the email template file
COPY ./internal/mailer/templates/user_welcome.tmpl ./internal/mailer/templates/user_welcome.tmpl
# Install necessary tools
RUN apk add --no-cache bash
# Expose the application port
EXPOSE 4000
# Set environment variables
ENV DB_DSN=postgres://username:password@db:5432/openconnect?sslmode=disable \
SMTPPORT= \
SMTPSENDER= \
SMTPHOST= \
SMTPUSERNAME= \
SMTPPASS=
# Command to run the application
CMD ["./app"]