Skip to content

Commit

Permalink
updting docker file
Browse files Browse the repository at this point in the history
  • Loading branch information
p-shubh committed May 22, 2024
1 parent 4cd036e commit 00c6c92
Showing 1 changed file with 28 additions and 9 deletions.
37 changes: 28 additions & 9 deletions Dockerfile
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"]

0 comments on commit 00c6c92

Please sign in to comment.