-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
46 lines (33 loc) · 1.06 KB
/
Dockerfile
File metadata and controls
46 lines (33 loc) · 1.06 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
# Build stage
FROM golang:1.23-alpine AS builder
WORKDIR /app
# Install dependencies
RUN apk add --no-cache git
# Copy and download dependencies
COPY go.mod go.sum ./
RUN go mod download
# Copy source code
COPY . .
# Build the application
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o txn .
# Final stage
FROM alpine:3.19
WORKDIR /app
# Install CA certificates for HTTPS
RUN apk --no-cache add ca-certificates tzdata
# Copy the binary from the builder stage
COPY --from=builder /app/txn .
# Copy any static assets
COPY --from=builder /app/internal/ibbitot/index.html /app/internal/ibbitot/
COPY --from=builder /app/internal/ibbitot/admin.html /app/internal/ibbitot/
COPY --from=builder /app/internal/ibbitot/coffee-cup.png /app/internal/ibbitot/
COPY --from=builder /app/internal/tracker/server/index.html /app/internal/tracker/server/
# Create a non-root user and data directory
RUN adduser -D appuser && \
mkdir -p /data && \
chown -R appuser:appuser /data
USER appuser
# Expose port
EXPOSE 8080
# Command to run the application
CMD ["./txn"]