From 938af1ea36eb04f02e9327ef892ef151c9086aa9 Mon Sep 17 00:00:00 2001 From: Roger Gonzalez Date: Tue, 20 Feb 2024 08:45:20 -0300 Subject: [PATCH] Using multistage to get the cli from another prebuilt image --- Dockerfile | 25 ++----------------------- 1 file changed, 2 insertions(+), 23 deletions(-) diff --git a/Dockerfile b/Dockerfile index 9e9077d..b61473a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,33 +1,12 @@ -# First stage: Download and extract the Bitwarden CLI -FROM python:3.11.0-slim-bullseye as builder +FROM tangowithfoxtrot/bw-cli as builder -# Install dependencies for downloading and extracting Bitwarden CLI -RUN apt-get update && \ - apt-get install -y --no-install-recommends curl jq unzip - -# Download and extract Bitwarden CLI -# Taken from https://github.com/tangowithfoxtrot/bw-docker/blob/main/Dockerfile#L7 -RUN export VER=$(curl -H "Accept: application/vnd.github+json" https://api.github.com/repos/bitwarden/clients/releases | jq -r 'sort_by(.published_at) | reverse | .[].name | select( index("CLI") )' | sed 's:.*CLI v::' | head -n 1) && \ - curl -LO "https://github.com/bitwarden/clients/releases/download/cli-v${VER}/bw-linux-${VER}.zip" && \ - unzip *.zip && \ - chmod +x ./bw - -# Second stage: Build the final image FROM python:3.11.0-slim-bullseye -# Copy Bitwarden CLI from the builder stage -COPY --from=builder /bw /bin/bw +COPY --from=builder /usr/local/bin/bw /bin/bw -# Set up the working directory WORKDIR /bitwarden-to-keepass -# Copy the application files COPY . . -# Install Python dependencies RUN pip install --no-cache-dir --upgrade pip && \ pip install --no-cache-dir -r requirements.txt - -# Clean up unnecessary files to reduce image size -RUN apt-get clean && \ - rm -rf /var/lib/apt/lists/*