From e9e400c60d0d5e6222fa6d769fb4928ae4a3077d Mon Sep 17 00:00:00 2001 From: = <=> Date: Sat, 16 Nov 2024 17:16:50 -0800 Subject: [PATCH] Moving python and npm into docker image builds --- .github/workflows/build-base-image.yml | 28 +++++--------------- .github/workflows/build-image.yml | 10 ++++--- .github/workflows/deploy-redis.yml | 7 +++-- .github/workflows/update-home-deployment.yml | 9 +++---- Base.Dockerfile | 14 ++++++---- Dockerfile | 11 -------- 6 files changed, 29 insertions(+), 50 deletions(-) diff --git a/.github/workflows/build-base-image.yml b/.github/workflows/build-base-image.yml index ce86cb1..b9aa6a2 100644 --- a/.github/workflows/build-base-image.yml +++ b/.github/workflows/build-base-image.yml @@ -4,11 +4,11 @@ name: Build Base Image on: push: - paths-ignore: - - '**' - - '!Base.Dockerfile' - - '!requirements.txt' - - '!package-lock.json' + paths: + - 'Dockerfile.base' + - 'requirements.txt' + - 'package.json' + - 'package-lock.json' concurrency: group: deployment @@ -40,19 +40,6 @@ jobs: - name: Checkout code uses: actions/checkout@v4 - - name: Set up Node.js - uses: actions/setup-node@v4 - with: - node-version: 20 - - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install -r requirements.txt - - - name: Install Node.js dependencies - run: npm install - - name: Authenticate with GitHub Container Registry uses: docker/login-action@v2 with: @@ -60,14 +47,11 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Copy Base.Dockerfile to Dockerfile - run: | - cp Base.Dockerfile Dockerfile - - name: Build and Push Container to GitHub Container Registry uses: docker/build-push-action@v5 with: context: . + file: Base.Dockerfile push: true tags: ghcr.io/${{ github.repository }}/crank-base:${{ github.sha }} diff --git a/.github/workflows/build-image.yml b/.github/workflows/build-image.yml index ebf9de2..21f1d0c 100644 --- a/.github/workflows/build-image.yml +++ b/.github/workflows/build-image.yml @@ -3,7 +3,14 @@ name: Build Image on: + workflow_run: + workflows: [ "Build Base Image" ] + types: + - completed + push: + paths: + - '.github/workflows/build-image.yml' paths-ignore: - '.github/**' - 'seeds/**' @@ -43,9 +50,6 @@ jobs: - name: Checkout code uses: actions/checkout@v4 - - name: Run webpack - run: npx webpack - - name: Authenticate with GitHub Container Registry uses: docker/login-action@v2 with: diff --git a/.github/workflows/deploy-redis.yml b/.github/workflows/deploy-redis.yml index 7a33827..fe13be6 100644 --- a/.github/workflows/deploy-redis.yml +++ b/.github/workflows/deploy-redis.yml @@ -5,10 +5,9 @@ on: push: branches: - main - paths-ignore: - - '**' - - '!.github/workflows/deploy-redis.yml' - - '!k8s/redis.yml' + paths: + - '.github/workflows/deploy-redis.yml' + - 'k8s/redis.yml' jobs: deploy-home-k3s: diff --git a/.github/workflows/update-home-deployment.yml b/.github/workflows/update-home-deployment.yml index ae80726..19529af 100644 --- a/.github/workflows/update-home-deployment.yml +++ b/.github/workflows/update-home-deployment.yml @@ -5,11 +5,10 @@ on: push: branches: - main - paths-ignore: - - '**' - - '!.github/workflows/update-home-deployment.yml' - - '!k8s/crank.yml' - - '!k8s/crank-configmap.yml' + paths: + - '.github/workflows/update-home-deployment.yml' + - 'k8s/crank.yml' + - 'k8s/crank-configmap.yml' concurrency: group: deployment diff --git a/Base.Dockerfile b/Base.Dockerfile index 1a6b0a4..519d589 100644 --- a/Base.Dockerfile +++ b/Base.Dockerfile @@ -7,20 +7,24 @@ WORKDIR /app # Add current directory code to /app in container ADD . /app -COPY .env-prod .env - -# fixing busybox vulnerabilities identified by synk +# Fixing busybox vulnerabilities identified by Snyk RUN apk add --no-cache --upgrade busybox RUN apk add --no-cache busybox-extras +# Install build dependencies RUN apk add --no-cache --virtual build-deps gcc musl-dev libffi-dev pkgconf mariadb-dev + +# Install runtime dependencies RUN apk add --no-cache mariadb-connector-c-dev + +# Install Python dependencies RUN pip install --no-cache-dir -r requirements.txt + +# Remove build dependencies RUN apk del build-deps # Install Node.js and npm -RUN apk update -RUN apk add nodejs npm +RUN apk update && apk add --no-cache nodejs npm # Install npm dependencies RUN npm install \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index cddc963..acb5d29 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,17 +11,6 @@ WORKDIR /app # Add current directory code to /app in container ADD . /app -COPY .env-prod .env - -# fixing busybox vulnerabilities identified by synk -RUN apk add --no-cache --upgrade busybox -RUN apk add --no-cache busybox-extras - -RUN apk add --no-cache --virtual build-deps gcc musl-dev libffi-dev pkgconf mariadb-dev -RUN apk add --no-cache mariadb-connector-c-dev -RUN pip install --no-cache-dir -r requirements.txt -RUN apk del build-deps - # Run Webpack to build the assets RUN npx webpack