-
Notifications
You must be signed in to change notification settings - Fork 6
/
Dockerfile
48 lines (34 loc) · 991 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
FROM golang:1.22-alpine as build
# Set the working directory
WORKDIR /go/src/app
# Cache dependencies
COPY ["go.mod", "go.sum", "./"]
# Download dependencies
RUN ["go", "mod", "download"]
# Copy project files
COPY . .
# The cgo tool is enabled by default for native builds on systems where it is expected to work.
# It is disabled by default when cross-compiling
ENV CGO_ENABLED=0
# Controls the source of Go module downloads
# Can help assure builds are deterministic and secure.
ENV GOPROXY=https://proxy.golang.org
# Executable filename (binary file)
ENV APP_NAME=insta-fetcher
# Build binary file
RUN ["go", "build", "-o", "build/${APP_NAME}", "cmd/bot/main.go"]
#
# Development build
#
FROM build as dev
# Run the application via Go
CMD ["go", "run", "."]
#
# Production build
#
FROM gcr.io/distroless/static-debian12 as prod
# Set the working directory
WORKDIR /home/app/
COPY --from=build /go/src/app/build/${APP_NAME} ./
# Execute the binary file
CMD ["./${APP_NAME}"]