-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
28 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,32 @@ | ||
FROM golang:1.19-alpine as builder | ||
# Start with the official Golang base image | ||
FROM golang:1.20-alpine AS builder | ||
|
||
# Set the Current Working Directory inside the container | ||
WORKDIR /app | ||
COPY go.mod . | ||
COPY go.sum . | ||
RUN apk add build-base | ||
|
||
# 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 code into the container | ||
COPY . . | ||
RUN apk add --no-cache git && go build -o discord-sepio ./src && apk del git | ||
|
||
FROM alpine | ||
WORKDIR /app | ||
COPY --from=builder /app/discord-sepio . | ||
CMD [ "./discord-sepio" ] | ||
# Build the Go app | ||
RUN go build -o main . | ||
|
||
# Start a new stage from scratch | ||
FROM alpine:latest | ||
|
||
# Set the Current Working Directory inside the container | ||
WORKDIR /root/ | ||
|
||
# Copy the Pre-built binary file from the previous stage | ||
COPY --from=builder /app/main . | ||
|
||
# Expose port 8080 to the outside world | ||
EXPOSE 8080 | ||
|
||
# Command to run the executable | ||
CMD ["./main"] |