Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
167 lines (142 loc) · 7.46 KB
/
Copy pathDockerfile
File metadata and controls
167 lines (142 loc) · 7.46 KB
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
FROM ubuntu:26.10@sha256:262df65c0ec6bf8d9dcc87454f4330a05fae4b97825f45854af3b136666584c2 AS installer-env
ENV DEBIAN_FRONTEND=noninteractive
ARG TARGETARCH
ENV PS_VERSION=7.6.9
RUN --mount=type=cache,target=/var/lib/apt \
--mount=type=cache,target=/var/cache/apt \
apt-get update \
&& apt-get install --no-install-recommends -y curl less locales ca-certificates && \
case "${TARGETARCH}" in \
amd64) ARCH="x64"; PS_SHA256="1da6d6d6035d651f20e70ddee7c4c15ac6ab8b9fb40ee92240d91263f28a884b" ;; \
arm64) ARCH="arm64"; PS_SHA256="02eb9991af447c7e7fe881acde195961afd397c40b8eb1c2b3856b84ec2d85f2" ;; \
*) echo "Unsupported architecture: ${TARGETARCH}" >&2; exit 1 ;; \
esac && \
curl --fail --location -o /tmp/powershell.tar.gz https://github.com/PowerShell/PowerShell/releases/download/v${PS_VERSION}/powershell-${PS_VERSION}-linux-${ARCH}.tar.gz && \
echo "${PS_SHA256} /tmp/powershell.tar.gz" | sha256sum --check --strict
FROM ubuntu:26.10@sha256:262df65c0ec6bf8d9dcc87454f4330a05fae4b97825f45854af3b136666584c2 AS base
WORKDIR /app
ARG TARGETARCH
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && \
apt-get install -y curl unzip ca-certificates zip tzdata wget gnupg2 bzip2 apt-transport-https locales locales-all lsb-release git python3-crcmod python3-openssl --no-install-recommends && \
update-ca-certificates && \
apt-get clean
RUN apt-get update && apt-get upgrade -y && \
rm -Rf /var/lib/apt/lists/* && \
apt-get clean
RUN locale-gen en_US.UTF-8
RUN update-locale LANG=en_US.UTF-8
RUN curl -sL https://github.com/flanksource/deps/releases/latest/download/deps-linux-${TARGETARCH}.tar.gz -o deps-linux-${TARGETARCH}.tar.gz && \
tar -xzf deps-linux-${TARGETARCH}.tar.gz -C /usr/bin && \
rm deps-linux-${TARGETARCH}.tar.gz
RUN --mount=type=bind,target=. \
--mount=type=secret,id=GITHUB_TOKEN,env=GITHUB_TOKEN \
deps --no-progress install bun@stable uv@stable kubectl@stable jq yq sops stern/stern flux@stable helm@stable --bin-dir /usr/bin && \
rm -rf /root/.deps
RUN if [ "${TARGETARCH}" = "amd64" ]; then \
curl -L "https://github.com/brocode/fblog/releases/latest/download/fblog" -o /usr/bin/fblog && \
chmod +x /usr/bin/fblog; \
else \
echo "fblog binary not available for $ARCH, building from source..." && \
apt-get update && apt-get install -y build-essential --no-install-recommends && \
curl https://sh.rustup.rs -sSf | sh -s -- -y && \
$HOME/.cargo/bin/cargo install fblog && \
mv $HOME/.cargo/bin/fblog /usr/bin/fblog && \
apt-get autoremove build-essential -y && \
apt-get clean && \
$HOME/.cargo/bin/rustup self uninstall -y; \
fi
ARG POWERSHELL_VERSION=7.6.9
# Define ENVs for Localization/Globalization
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false
ENV LC_ALL=en_US.UTF-8
ENV LANG=en_US.UTF-8
ENV PS_INSTALL_FOLDER=/opt/powershell
ENV POWERSHELL_TELEMETRY_OPTOUT=1
ENV PSModuleAnalysisCachePath=/var/cache/microsoft/powershell/PSModuleAnalysisCache/ModuleAnalysisCache
ENV PS_VERSION=7.6.9
RUN --mount=from=installer-env,target=/mnt/pwsh,source=/tmp \
--mount=type=cache,target=/var/lib/apt \
--mount=type=cache,target=/var/cache/apt \
apt-get update && \
apt-get install -y --no-install-recommends \
less locales \
gss-ntlmssp \
libicu78 \
libssl3 \
libc6 \
libgcc-s1 \
libgssapi-krb5-2 \
liblttng-ust1 \
libstdc++6 \
zlib1g && \
mkdir -p /opt/powershell && \
tar zxf /mnt/pwsh/powershell.tar.gz -C /opt/powershell && \
chmod +x /opt/powershell/pwsh && \
ln -s /opt/powershell/pwsh /usr/bin/pwsh && \
# install module outsize of powershell due to segfaults on emulated arm
curl -L -o powershell-yaml.nupkg https://www.powershellgallery.com/api/v2/package/powershell-yaml/0.4.10 && \
mkdir -p $HOME/.local/share/powershell/Modules/powershell-yaml/0.4.10 && \
unzip powershell-yaml.nupkg -x */.rels *.nuspec *.xml -d $HOME/.local/share/powershell/Modules/powershell-yaml/0.4.10 && \
rm powershell-yaml.nupkg && \
apt-get clean
# Minimalized Google cloud sdk
FROM base AS gcloud-installer
ENV GCLOUD_PATH=/opt/google-cloud-sdk
ENV PATH=$GCLOUD_PATH/bin:$PATH
ENV CLOUDSDK_PYTHON=/usr/bin/python3
# Download and install cloud sdk. Review the components I install, you may not need them.
RUN GCLOUDCLI_URL="https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-cli-linux-x86_64.tar.gz" && \
if [ "${TARGETARCH}" = "arm64" ]; then \
GCLOUDCLI_URL="https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-cli-linux-arm.tar.gz"; \
fi && \
curl $GCLOUDCLI_URL -o gcloud.tar.gz && \
tar xzf gcloud.tar.gz -C /opt && \
rm gcloud.tar.gz && \
rm -rf $GCLOUD_PATH/platform/bundledpythonunix && \
gcloud config set core/disable_usage_reporting true && \
gcloud config set component_manager/disable_update_check true && \
gcloud config set metrics/environment github_docker_image && \
gcloud components remove -q bq && \
gcloud components install -q beta kubectl-oidc gke-gcloud-auth-plugin && \
rm -rf $(find $GCLOUD_PATH/ -regex ".*/__pycache__") && \
rm -rf $GCLOUD_PATH/.install/.backup && \
rm -rf $GCLOUD_PATH/bin/anthoscli && \
gcloud --version
FROM base AS final
# Install all locales
RUN locale-gen en_US.UTF-8
RUN update-locale LANG=en_US.UTF-8
RUN apt-get install -y locales locales-all
ENV PATH=/opt/google-cloud-sdk/bin:$PATH
ENV CLOUDSDK_PYTHON=/usr/bin/python3
COPY --from=gcloud-installer /opt/google-cloud-sdk /opt/google-cloud-sdk
# This is to be able to update gcloud packages
RUN git config --system credential.'https://source.developers.google.com'.helper gcloud.sh
# Azure CLI
RUN apt-get update && apt-get install -y --no-install-recommends apt-transport-https ca-certificates curl gnupg lsb-release && \
mkdir -p /etc/apt/keyrings && \
curl -sLSk https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor | tee /etc/apt/keyrings/microsoft.gpg > /dev/null && \
chmod go+r /etc/apt/keyrings/microsoft.gpg
# Microsoft does not publish an azure-cli suite for every Ubuntu release (lsb_release -cs returns an unpublished codename on 26.10), so pin the newest published suite
ARG AZ_DIST=noble
RUN echo "Types: deb" > /etc/apt/sources.list.d/azure-cli.sources && \
echo "URIs: https://packages.microsoft.com/repos/azure-cli/" >> /etc/apt/sources.list.d/azure-cli.sources && \
echo "Suites: ${AZ_DIST}" >> /etc/apt/sources.list.d/azure-cli.sources && \
echo "Components: main" >> /etc/apt/sources.list.d/azure-cli.sources && \
echo "Architectures: $(dpkg --print-architecture)" >> /etc/apt/sources.list.d/azure-cli.sources && \
echo "Signed-by: /etc/apt/keyrings/microsoft.gpg" >> /etc/apt/sources.list.d/azure-cli.sources && \
apt-get update && apt-get install -y --no-install-recommends azure-cli && \
# azure-cli bundles its own Python packages; upgrade the ones with known CVEs ahead of the next azure-cli release
/opt/az/bin/python3 -m pip install --no-cache-dir --root-user-action=ignore --upgrade pip urllib3 cryptography pyopenssl oauthlib && \
/opt/az/bin/python3 -m pip check
# AWS CLI
RUN AWSCLI_URL="https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" && \
if [ "${TARGETARCH}" = "arm64" ]; then \
AWSCLI_URL="https://awscli.amazonaws.com/awscli-exe-linux-aarch64.zip"; \
fi && \
curl "${AWSCLI_URL}" -o "awscliv2.zip" && \
unzip -q awscliv2.zip && ./aws/install -i /opt/aws -b /usr/bin/ && \
rm awscliv2.zip && \
rm -rf ./aws && \
aws --version