-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
32 lines (22 loc) · 717 Bytes
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# Use the official Golang image to build the Go application
FROM golang:1.22-alpine AS build
# Set the working directory inside the container
WORKDIR /app
# Copy the Go modules files
COPY go.mod go.sum ./
# Download and cache the Go modules
RUN go mod download
# Copy the rest of the application code
COPY . .
# Build the Go application
RUN go build -o /tiny-url-service
# Use a minimal image to run the application
FROM alpine:latest
# Set the working directory inside the container
WORKDIR /root/
# Copy the built application from the build stage
COPY --from=build /tiny-url-service .
# Expose the port on which the service will run
EXPOSE 8080
# Command to run the application
CMD ["./tiny-url-service"]