Skip to content

Commit

Permalink
Moving python and npm into docker image builds
Browse files Browse the repository at this point in the history
  • Loading branch information
= committed Nov 17, 2024
1 parent af52c89 commit e9e400c
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 50 deletions.
28 changes: 6 additions & 22 deletions .github/workflows/build-base-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -40,34 +40,18 @@ 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:
registry: ghcr.io
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 }}

Expand Down
10 changes: 7 additions & 3 deletions .github/workflows/build-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/**'
Expand Down Expand Up @@ -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:
Expand Down
7 changes: 3 additions & 4 deletions .github/workflows/deploy-redis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
9 changes: 4 additions & 5 deletions .github/workflows/update-home-deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 9 additions & 5 deletions Base.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
11 changes: 0 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit e9e400c

Please sign in to comment.