-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDockerfile
33 lines (22 loc) · 846 Bytes
/
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
# Use the official Golang image as the base image
FROM golang:1.21.4-alpine AS builder
# Set the current working directory inside the container
WORKDIR /app
# Copy the entire project
COPY . .
# Download all dependencies. Dependencies will be cached if the go.mod and go.sum files are not changed
RUN go mod download
# Install upx and binutils
RUN apk add --no-cache upx binutils
# Build the Go app
RUN go build -ldflags="-s -w" -o /app/bin/anki-card ./cmd/anki-card/main.go
RUN strip /app/bin/anki-card
# Compress the binary
RUN upx -9 /app/bin/anki-card
# Use a smaller base image for the final build
FROM alpine:latest
# Copy the pre-built binary and config files from the builder stage
COPY --from=builder /app/bin/anki-card /app/
COPY --from=builder /app/configs /app/configs
# Command to run the executable
CMD ["/app/anki-card"]