-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
43 lines (31 loc) · 1.07 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
# docker build -t imqs/router:latest --build-arg SSH_KEY="`cat ~/.ssh/id_rsa`" .
##################################
# builder image
##################################
FROM golang:1.22 AS builder
ARG SSH_KEY
RUN mkdir /build
WORKDIR /build
# Authorize SSH Host
RUN mkdir -p /root/.ssh && \
chmod 0700 /root/.ssh && \
ssh-keyscan github.com > /root/.ssh/known_hosts
# We need this key so that we can read our private IMQS git repos from github
RUN echo "$SSH_KEY" > /root/.ssh/id_rsa && \
chmod 600 /root/.ssh/id_rsa
RUN git config --global url."[email protected]:".insteadOf "https://github.com/"
# Cache downloads
COPY go.mod go.sum /build/
RUN go mod download
# Compile
COPY . /build/
RUN go build -o router main.go
####################################
# deployed image
####################################
FROM imqs/ubuntu-base:24.04
COPY --from=builder /build/router /opt/router
EXPOSE 80
EXPOSE 443
HEALTHCHECK CMD curl --fail http://localhost/router/ping || exit 1
ENTRYPOINT ["wait-for-nc.sh", "config:80", "--", "/opt/router"]