eljur/Dockerfile
2024-01-27 21:44:51 +03:00

31 lines
746 B
Docker

# Stage 1: Build the Rod application
FROM golang:1.21.2 AS builder
# Set the working directory inside the Docker image
WORKDIR /app
# Copy the go mod and sum files, and download dependencies
COPY go.mod go.sum /app/
RUN go mod download
# Copy the source code into the Docker image
COPY *.go /app/
# Build the Rod application
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o main .
# Stage 2: Use a slim image for the runnable container
FROM alpine:3.14 as runtime
# Set the working directory
WORKDIR /root/
# Install browser
RUN apk add chromium
# Copy the binary from the builder stage
COPY --from=builder /app/main .
COPY Golang/ .
# Set the binary as the default command to run when starting the container
CMD ["./main"]