make this will make it smaller, idk
This commit is contained in:
22
Dockerfile
22
Dockerfile
@ -1,18 +1,28 @@
|
|||||||
# Use the official Golang image as the base image
|
# Use the official Golang image as the base image
|
||||||
|
FROM golang:latest AS builder
|
||||||
|
|
||||||
|
# Set the working directory inside the container
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Copy the source code to the container
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
# Build the Go application
|
||||||
|
RUN make
|
||||||
|
|
||||||
|
# Stage 2: Create the final image with a smaller base image
|
||||||
FROM golang:latest
|
FROM golang:latest
|
||||||
|
|
||||||
# Set the working directory inside the container
|
# Set the working directory inside the container
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Copy the Makefile and source code to the container
|
# Copy the necessary files from the builder stage to the final image
|
||||||
COPY Makefile .
|
COPY --from=builder /app/bin/paste /app/bin/paste
|
||||||
COPY . .
|
COPY --from=builder /app/public /app/public
|
||||||
|
|
||||||
# Build the Go application using the Makefile
|
|
||||||
RUN make build
|
|
||||||
|
|
||||||
# Expose the port that the application listens on
|
# Expose the port that the application listens on
|
||||||
EXPOSE 8080
|
EXPOSE 8080
|
||||||
|
ENV PORT=8080
|
||||||
|
|
||||||
# Run the Go application
|
# Run the Go application
|
||||||
CMD ["./bin/paste"]
|
CMD ["./bin/paste"]
|
Reference in New Issue
Block a user