forked from championswimmer/onepixel_backend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
40 lines (28 loc) · 1.18 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
FROM --platform=amd64 golang:1.22 AS builder
# Install CA certificates
RUN apt-get update && apt-get install -y ca-certificates
RUN apt-get install -y build-essential
# Move to working directory (/build).
RUN mkdir /build
WORKDIR /build
# Copy and download dependency using go mod.
COPY go.mod go.sum ./
RUN go mod download
# Copy the code into the container.
COPY . .
# Set necessary environment variables needed for our image and build the API server.
ENV CGO_ENABLED=1 GOOS=linux GOARCH=amd64
# RUN go build -ldflags="-s -w" -o onepixel ./src/main.go
RUN make build DOCS=false
FROM --platform=amd64 debian:bookworm-slim
LABEL maintainer="Arnav Gupta <[email protected]> (https://arnav.tech)"
LABEL description="OnePixel is a simple, self-hosted, one pixel web analytics tool"
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
RUN mkdir /app
# Copy binary and config files from /build to root folder of scratch container.
COPY --from=builder ["/build/*.env", "/app/"]
COPY --from=builder ["/build/bin/onepixel", "/app/"]
COPY --from=builder ["/build/public_html", "/app/public_html"]
# Command to run when starting the container.
WORKDIR /app
CMD [ "./onepixel" ]