-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
100 lines (86 loc) · 3 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
### -----------------------
# --- Stage: development
# --- Purpose: Local development environment
# --- https://hub.docker.com/_/golang
# --- https://github.com/microsoft/vscode-remote-try-go/blob/master/.devcontainer/Dockerfile
### -----------------------
FROM golang:1.21.3-bullseye as dev
# Avoid warnings by switching to noninteractive
ENV DEBIAN_FRONTEND=noninteractive
ENV CGO_ENABLED=0
# postgresql-support: Add the official postgres repo to install the matching postgresql-client tools of your stack
# https://wiki.postgresql.org/wiki/Apt
# run lsb_release -c inside the container to pick the proper repository flavor
# e.g. stretch=>stretch-pgdg, buster=>buster-pgdg, bullseye=>bullseye-pgdg
RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ bullseye-pgdg main" \
| tee /etc/apt/sources.list.d/pgdg.list \
&& wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc \
| apt-key add -
# Install required system dependencies
RUN apt-get update \
&& apt-get install -y \
#
# Mandadory minimal linux packages
# Installed at development stage and app stage
# Do not forget to add mandadory linux packages to the final app Dockerfile stage below!
#
# -- START MANDADORY --
ca-certificates \
# --- END MANDADORY ---
#
# Development specific packages
# Only installed at development stage and NOT available in the final Docker stage
# based upon
# https://github.com/microsoft/vscode-remote-try-go/blob/master/.devcontainer/Dockerfile
# https://raw.githubusercontent.com/microsoft/vscode-dev-containers/master/script-library/common-debian.sh
#
# icu-devtools: https://stackoverflow.com/questions/58736399/how-to-get-vscode-liveshare-extension-working-when-running-inside-vscode-remote
# graphviz: https://github.com/google/pprof#building-pprof
# -- START DEVELOPMENT --
apt-utils \
dialog \
openssh-client \
less \
iproute2 \
procps \
lsb-release \
locales \
sudo \
bash-completion \
bsdmainutils \
graphviz \
xz-utils \
postgresql-client-15 \
icu-devtools \
tmux \
rsync \
git \
tzdata \
# --- END DEVELOPMENT ---
#
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
RUN go install github.com/volatiletech/sqlboiler/v4@latest && \
go install github.com/volatiletech/sqlboiler/v4/drivers/sqlboiler-psql@latest && \
go install github.com/rubenv/sql-migrate/sql-migrate@latest && \
go install github.com/cosmtrek/air@latest
COPY go.mod go.sum ./
RUN go mod download
COPY . .
CMD ["air", "-c", ".air.toml"]
# Build Image
FROM golang:1.21.3-bullseye as build
ENV CGO_ENABLED=0
RUN apk add --no-cache --update git tzdata ca-certificates
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN go build -o main .
# Production Image (distroless) with only the binary
FROM gcr.io/distroless/static-debian11 as app
COPY --from=build /app/main /app/main
COPY --from=build /app/embedding /app/embedding
WORKDIR /app
CMD ["./main", "run"]