-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
71 lines (46 loc) · 1.82 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
FROM golang:1.20-bookworm AS base
ENV \
CGO_ENABLED=0 \
GOOS=linux \
LC_ALL=C.UTF-8
WORKDIR /app
RUN --mount=type=ssh apt-get update && apt-get install -y \
git \
openssh-client \
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \
&& rm -rf /var/lib/apt/lists/* \
&& mkdir -p -m 0700 ~/.ssh && ssh-keyscan github.com | sort > ~/.ssh/known_hosts
COPY go.mod .
COPY go.sum .
RUN go mod download
COPY . .
# dev-shell ------------------------------
FROM base as devel_shell
WORKDIR /app
COPY . /app
RUN --mount=type=ssh apt-get update && apt-get install -y \
zsh \
vim nano \
python3 python3-pip python3-yaml \
&& sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" \
&& echo "source /root/.profile" >>/root/.zshrc \
&& pip3 install --user --break-system-packages pre-commit git-up \
# Map the special names to docker host internal ip because 127.0.0.1 is *container* localhost on login
&& echo "sed 's/.*localmaeher.*//g' /etc/hosts >/etc/hosts.new && cat /etc/hosts.new >/etc/hosts" >>/root/.profile \
&& echo "echo \"\$(getent hosts host.docker.internal | awk '{ print $1 }') localmaeher.pvarki.fi mtls.localmaeher.pvarki.fi\" >>/etc/hosts" >>/root/.profile \
&& true
ENTRYPOINT ["/bin/zsh", "-l"]
# builder ------------------------------
FROM base as builder
WORKDIR /app
# Build the kraftwerk
RUN go build -o cmd/kw_product_init kw_product_init.go
# Move to /dist directory as the place for resulting binary folder
WORKDIR /dist
# Copy binary from build to main folder
RUN cp /app/cmd/kw_product_init .
# production ------------------------------
FROM scratch as production
COPY --from=builder /dist/kw_product_init /
# Command to run the executable
ENTRYPOINT ["/kw_product_init"]