-
Notifications
You must be signed in to change notification settings - Fork 9
/
Dockerfile
36 lines (27 loc) · 1.12 KB
/
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
FROM golang:1-bullseye AS build
WORKDIR /usr/src/app
# pre-copy/cache go.mod for pre-downloading dependencies and only redownloading them in subsequent builds if they change
COPY ./go.mod ./go.sum ./
RUN go mod download && go mod verify
COPY ./cmd/conduit/main.go ./
COPY ./internal ./internal
RUN go build -v -o /usr/local/bin/app ./main.go
# Stage two - we'll utilize a second container to run our built binary from our first container - slim containers!
FROM debian:bullseye-slim as deploy
# Let's install all the necessary runtime tools on the container
RUN set -eux; \
export DEBIAN_FRONTEND=noninteractive; \
apt update; \
apt install -y --no-install-recommends ca-certificates; \
apt clean autoclean; \
apt autoremove -y; \
rm -rf /var/lib/{apt,dpkg,cache,log}/;
# Let's work from a self contained directory for all of our deployment needs
WORKDIR /deploy
# We need the artifact from the build container, so let's grab it
COPY --from=build /usr/local/bin/app ./
# Let's expose port 80 as we'll need fly's internal port mapping also assumes 80
EXPOSE 80
EXPOSE 443
# Finally, boot up the API
CMD ["./app"]