-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
93 lines (72 loc) · 2.64 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
ARG tag=12-slim
################################## Temp Layer ##################################
FROM debian:${tag} AS temp
RUN mkdir -p /etc/apt/keyrings
### Install helper requirements
RUN apt-get update \
&& apt-get satisfy -y --no-install-recommends \
"ca-certificates (>=20230311)" \
"curl (>=7.88)" \
"gnupg (>=2.2)" \
"unzip (>=6.0)" \
&& rm -rf /var/lib/apt/lists/*
### Add non-standard repository keys
RUN --mount=src=src,dst=/build \
/build/add-gpg-keyrings.sh /build/extra.gpg.txt \
&& chmod a+r /etc/apt/keyrings/*.gpg
################################## Base Layer ##################################
FROM debian:${tag} AS base
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
ENV LANG=en_US.UTF-8
COPY src/rootfs /
COPY --from=temp /etc/apt/keyrings /etc/apt/keyrings
### Add application user
RUN adduser \
--disabled-password \
--gecos '' \
--uid 1000 \
kloud
### Install packages
RUN --mount=src=src,dst=/build \
apt-get update \
&& apt-get satisfy -y --no-install-recommends \
"ca-certificates (>=20230311)" \
&& apt-get update \
&& apt-get satisfy -y --no-install-recommends $(cat /build/packages.apt) \
&& rm -rf \
/var/lib/apt/lists/* \
/usr/lib/python3.11/EXTERNALLY-MANAGED \
&& locale-gen \
&& ln -fs "$(which python3)" /usr/bin/python
############################### Dependency Layer ###############################
FROM temp AS deps
WORKDIR /usr/local/bin
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
ARG TARGETARCH
# renovate: source=github-releases dep=google/go-containerregistry
ARG crane_version=0.20.2
RUN case ${TARGETARCH} in "arm64") file=arm64 ;; "amd64") file=x86_64 ;; esac \
&& curl -fsSL "https://github.com/google/go-containerregistry/releases/download/v${crane_version}/go-containerregistry_Linux_${file}.tar.gz" \
| tar -xzf - \
&& curl -fsSL "https://mirror.openshift.com/pub/openshift-v4/${file}/clients/ocp/4.17.5/openshift-client-linux.tar.gz" \
| tar -xzf - -C /tmp \
&& cp /tmp/oc .
RUN chown -R root:root /usr/local/bin \
&& chmod -R 755 /usr/local/bin
############################### Application layer ##############################
FROM base
USER kloud
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
WORKDIR /workspace
ENV USER=kloud
ENV PATH=${PATH}:/home/kloud/.local/bin
### Install user packages & extensions
RUN --mount=src=src,dst=/build \
helm plugin install https://github.com/databus23/helm-diff \
&& pip install --no-cache-dir -r /build/requirements.txt \
&& pip cache purge \
&& ansible-galaxy install -r /build/requirements.yaml \
&& rm -rf \
/home/kloud/.ansible/galaxy_cache \
/home/kloud/.cache/helm
ENTRYPOINT ["ansible-playbook"]