-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
39 lines (27 loc) · 1.06 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
# Use the official Go image for building the application
FROM golang:1.23-alpine AS build
LABEL org.opencontainers.image.source=https://github.com/inp-net/automirror
LABEL org.opencontainers.image.description="Automatically create push-mirrors from a gitlab instance to a github organization for public repositories having a certain topic"
LABEL org.opencontainers.image.licenses="MIT"
# Set the working directory inside the container
WORKDIR /app
# Copy the Go modules files
COPY go.mod go.sum ./
# Download Go module dependencies
RUN go mod download
# Copy the source code into the container
COPY . .
ARG VERSION=dev
ARG COMMIT=unknown
# Build the Go application
RUN go build --ldflags "-X 'main.Version=$VERSION' -X 'main.Commit=$COMMIT'" -o automirror .
# Use a minimal base image to run the app
FROM alpine:3.21
# Set the working directory inside the container
WORKDIR /app
# Install git
RUN apk add --no-cache git
# Copy the compiled binary from the build stage
COPY --from=build /app/automirror /app/automirror
# Run the compiled Go application
CMD ["/app/automirror"]