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
|
2025-11-18 15:20:14 +01:00
|
|
|
RUN CGO_ENABLED=0 GOOS=linux go build -o main .
|
2025-08-04 17:45:44 +02:00
|
|
|
|
|
|
|
|
# Start a new stage from alpine:latest
|
2025-11-18 15:20:14 +01:00
|
|
|
FROM alpine:latest 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
|
2025-10-27 17:58:42 +01:00
|
|
|
ARG STORAGE_URL
|
2025-10-29 09:24:15 +01:00
|
|
|
ARG STORAGE_TOKEN
|
2025-08-04 17:45:44 +02:00
|
|
|
|
2025-11-18 15:20:14 +01:00
|
|
|
RUN apk add --no-cache ffmpeg ca-certificates libc6-compat
|
2025-08-04 17:45:44 +02:00
|
|
|
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
|
2025-10-27 17:58:42 +01:00
|
|
|
ENV STORAGE_URL=$STORAGE_URL
|
2025-10-29 09:24:15 +01:00
|
|
|
ENV STORAGE_TOKEN=$STORAGE_TOKEN
|
2025-08-04 17:45:44 +02:00
|
|
|
|
|
|
|
|
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
|
2026-01-07 13:26:00 +01:00
|
|
|
COPY ./test.jpg /app/test.jpg
|
|
|
|
|
COPY ./scripts /app/scripts
|
|
|
|
|
COPY ./categorie.xml /app/categorie.xml
|
|
|
|
|
COPY ./caratteristiche.xml /app/caratteristiche.xml
|
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
|
2025-11-18 15:20:14 +01:00
|
|
|
# create folders
|
2025-08-04 17:45:44 +02:00
|
|
|
RUN mkdir images
|
2025-11-18 15:20:14 +01:00
|
|
|
RUN mkdir videos
|
2026-01-13 10:53:27 +01:00
|
|
|
RUN mkdir failed_requests
|
2025-08-04 17:45:44 +02:00
|
|
|
|
|
|
|
|
RUN apk add curl
|
|
|
|
|
|
|
|
|
|
# Expose port 1323 to the outside world
|
|
|
|
|
EXPOSE 1323
|
|
|
|
|
|
|
|
|
|
# Command to run the executable
|
|
|
|
|
CMD ["./main"]
|