fix: Dockerfile

This commit is contained in:
Urko. 2024-04-29 21:50:35 +02:00
parent 5860f81aa2
commit ad77710ad1
1 changed files with 15 additions and 17 deletions

View File

@ -2,29 +2,27 @@ FROM golang:1.22 as builder
WORKDIR /app
# Copy the local package files to the container's workspace.
COPY go.mod go.sum ./
RUN go mod download
COPY internal ./internal
COPY pk ./pk
ARG PORT
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o /app/webhook-ci /app/main.go
# Copy the project code into the container
COPY . .
FROM alpine:3.15
# Build the Go app
RUN CGO_ENABLED=0 GOOS=linux go build -v -o git-webhook-ci
# Install ca-certificates, ffmpeg (which includes ffprobe), Python, and yt-dlp
RUN apk --no-cache add ca-certificates ffmpeg python3 py3-pip \
&& python3 -m venv /opt/venv \
&& source /opt/venv/bin/activate \
&& pip install --no-cache-dir yt-dlp
# Use a small Alpine Linux image
FROM alpine:latest
ENV PATH="/opt/venv/bin:$PATH"
# Set the working directory
WORKDIR /root/
COPY --from=builder /app/banana-byte /app/banana-byte
COPY --from=builder /app/web /app/web
# Copy the binary from the builder stage
COPY --from=builder /app/git-webhook-ci .
ENV VIEWS_DIR="/app/web"
# Document that the service listens on port 8080.
EXPOSE 8080
EXPOSE $PORT
CMD ["/app/banana-byte"]
# Run the binary.
CMD ["./git-webhook-ci"]