use npm package on arm

This commit is contained in:
Tobias Trabelsi 2023-05-11 10:22:15 +02:00
parent c753737497
commit 2d399ff8ce
Signed by: lerentis
GPG Key ID: FF0C2839718CAF2E

View File

@ -1,12 +1,3 @@
FROM alpine:latest as builder
ARG BW_VERSION=2023.1.0
RUN apk add wget unzip
RUN cd /tmp && wget https://github.com/bitwarden/clients/releases/download/cli-v${BW_VERSION}/bw-linux-${BW_VERSION}.zip && \
unzip /tmp/bw-linux-${BW_VERSION}.zip
FROM alpine:3.17.3
LABEL org.opencontainers.image.source=https://github.com/Lerentis/bitwarden-crd-operator
@ -17,18 +8,36 @@ ARG PYTHON_VERSION=3.10.11-r0
ARG PIP_VERSION=22.3.1-r1
ARG GCOMPAT_VERSION=1.1.0-r0
ARG LIBCRYPTO_VERSION=3.0.8-r4
ARG BW_VERSION=2023.1.0
COPY --from=builder /tmp/bw /usr/local/bin/bw
COPY requirements.txt requirements.txt
COPY requirements.txt /requirements.txt
RUN set -eux; \
apk add --virtual build-dependencies wget unzip; \
ARCH="$(apk --print-arch)"; \
case "${ARCH}" in \
aarch64|arm64) \
apk add npm; \
npm install -g @bitwarden/cli@${BW_VERSION}; \
;; \
amd64|x86_64) \
cd /tmp; \
wget https://github.com/bitwarden/clients/releases/download/cli-v${BW_VERSION}/bw-linux-${BW_VERSION}.zip; \
unzip /tmp/bw-linux-${BW_VERSION}.zip; \
;; \
*) \
echo "Unsupported arch: ${ARCH}"; \
exit 1; \
;; \
esac; \
apk del --purge build-dependencies; \
addgroup -S -g 1000 bw-operator; \
adduser -S -D -u 1000 -G bw-operator bw-operator; \
mkdir -p /home/bw-operator; \
chown -R bw-operator /home/bw-operator; \
chmod +x /usr/local/bin/bw; \
apk add gcc musl-dev libstdc++ gcompat=${GCOMPAT_VERSION} python3=${PYTHON_VERSION} py3-pip=${PIP_VERSION} libcrypto3=${LIBCRYPTO_VERSION} libssl3=${LIBCRYPTO_VERSION}; \
pip install -r requirements.txt --no-warn-script-location; \
pip install -r /requirements.txt --no-warn-script-location; \
rm /requirements.txt; \
apk del --purge gcc musl-dev libstdc++;
COPY --chown=bw-operator:bw-operator src /home/bw-operator