fix: Dockerfile now builds a usable image
/ build-deploy (push) Successful in 2m3s
Details
/ build-deploy (push) Successful in 2m3s
Details
This commit is contained in:
parent
55f794e8ef
commit
3afbe2044e
11
Dockerfile
11
Dockerfile
|
@ -1,22 +1,23 @@
|
||||||
# Start from a Go base image
|
# Start from a Go base image
|
||||||
FROM golang:latest as builder
|
FROM golang:alpine3.19 AS builder
|
||||||
|
|
||||||
# Set the working directory
|
# Set the working directory
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Copy the source code into the container
|
# Copy the source code into the container
|
||||||
COPY . .
|
COPY . .
|
||||||
|
RUN go mod download
|
||||||
|
|
||||||
# Build the application
|
# Build the application
|
||||||
RUN go build -o mybot .
|
RUN CGO_ENABLED=0 GOOS=linux go build -o mybot .
|
||||||
|
|
||||||
# Use a small base image
|
# Use a small base image
|
||||||
FROM alpine:latest
|
FROM alpine:edge
|
||||||
|
|
||||||
WORKDIR /root/
|
WORKDIR /app/
|
||||||
|
|
||||||
# Copy the binary from the builder stage
|
# Copy the binary from the builder stage
|
||||||
COPY --from=builder /app/mybot .
|
COPY --from=builder /app/mybot /app/
|
||||||
|
|
||||||
# Command to run the executable
|
# Command to run the executable
|
||||||
CMD ["./mybot"]
|
CMD ["./mybot"]
|
||||||
|
|
Loading…
Reference in New Issue