2025-08-04 17:45:44 +02:00
|
|
|
# Start from the latest golang base image
|
2025-08-07 17:24:33 +02:00
|
|
|
FROM golang:1.24-bullseye AS builder
|
2025-08-04 17:45:44 +02:00
|
|
|
|
|
|
|
|
# Set the Current Working Directory inside the container
|
|
|
|
|
WORKDIR /app
|
|
|
|
|
|
|
|
|
|
# Copy go mod and sum files
|
|
|
|
|
COPY go.mod go.sum ./
|
|
|
|
|
|
|
|
|
|
# Download all dependencies. Dependencies will be cached if the go.mod and go.sum files are not changed
|
|
|
|
|
RUN go mod download
|
|
|
|
|
|
|
|
|
|
# Copy the source from the current directory to the Working Directory inside the container
|
|
|
|
|
COPY . .
|
|
|
|
|
|
|
|
|
|
# Build the Go app
|
|
|
|
|
RUN go build -o main .
|
|
|
|
|
|
|
|
|
|
# Start a new stage from alpine:latest
|
2025-10-10 15:11:09 +02:00
|
|
|
FROM alpine:3.22 AS runner
|
2025-08-04 17:45:44 +02:00
|
|
|
|
|
|
|
|
ARG POSTGRES_USER
|
|
|
|
|
ARG POSTGRES_PASSWORD
|
|
|
|
|
ARG POSTGRES_DB
|
|
|
|
|
ARG PGHOST
|
|
|
|
|
ARG PGPORT
|
|
|
|
|
ARG IMAGEOPTION
|
|
|
|
|
ARG CONCURRENT_IMAGES
|
|
|
|
|
ARG STORAGE_STRATEGY
|
|
|
|
|
ARG MINIO_ENDPOINT
|
|
|
|
|
ARG MINIO_PORT
|
|
|
|
|
ARG MINIO_ROOT_USER
|
|
|
|
|
ARG MINIO_ROOT_PASSWORD
|
|
|
|
|
|
|
|
|
|
RUN apk --no-cache add ca-certificates libc6-compat
|
|
|
|
|
ENV GOMEMLIMIT=2750MiB
|
|
|
|
|
ENV GOGC=100
|
|
|
|
|
ENV PGHOST=$PGHOST
|
|
|
|
|
ENV POSTGRES_DB=$POSTGRES_DB
|
|
|
|
|
ENV PGPORT=$PGPORT
|
|
|
|
|
ENV POSTGRES_USER=$POSTGRES_USER
|
|
|
|
|
ENV POSTGRES_PASSWORD=$POSTGRES_PASSWORD
|
|
|
|
|
ENV IMAGEOPTION=$IMAGEOPTION
|
|
|
|
|
ENV CONCURRENT_IMAGES=$CONCURRENT_IMAGES
|
|
|
|
|
ENV STORAGE_STRATEGY=$STORAGE_STRATEGY
|
|
|
|
|
ENV MINIO_ENDPOINT=$MINIO_ENDPOINT
|
|
|
|
|
ENV MINIO_PORT=$MINIO_PORT
|
|
|
|
|
ENV MINIO_ROOT_USER=$MINIO_ROOT_USER
|
|
|
|
|
ENV MINIO_ROOT_PASSWORD=$MINIO_ROOT_PASSWORD
|
|
|
|
|
|
|
|
|
|
WORKDIR /app
|
|
|
|
|
|
|
|
|
|
# Copy the Pre-built binary file from the previous stage
|
|
|
|
|
COPY --from=builder /app/main /app/.
|
|
|
|
|
COPY --from=builder /app/public /app/public
|
|
|
|
|
COPY --from=builder /app/test.jpg /app/test.jpg
|
2025-08-18 09:55:51 +02:00
|
|
|
COPY --from=builder /app/scripts /app/scripts
|
2025-08-18 10:22:02 +02:00
|
|
|
RUN chmod +x /app/scripts/*.sh
|
|
|
|
|
|
2025-08-04 17:45:44 +02:00
|
|
|
#COPY --from=builder /app/.env /app/.env
|
|
|
|
|
# create images and storage folder
|
|
|
|
|
RUN mkdir images
|
|
|
|
|
RUN mkdir storage
|
|
|
|
|
RUN mkdir storage/tmp
|
|
|
|
|
|
|
|
|
|
RUN apk add curl
|
|
|
|
|
|
|
|
|
|
# Expose port 1323 to the outside world
|
|
|
|
|
EXPOSE 1323
|
|
|
|
|
|
|
|
|
|
# Command to run the executable
|
|
|
|
|
CMD ["./main"]
|