Skip to content

Commit

Permalink
Fixing the Build using GH
Browse files Browse the repository at this point in the history
  • Loading branch information
pushyamig committed Dec 2, 2024
1 parent afbf7c0 commit 4574378
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 103 deletions.
20 changes: 11 additions & 9 deletions .github/workflows/build_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ on:
branches:
- main
- '[0-9][0-9][0-9][0-9].[0-9][0-9].*' # 2021.01.x
- 'issue_322'
- 'i322_gh_actions'
tags:
- '[0-9][0-9][0-9][0-9].[0-9][0-9].[0-9][0-9]' # 2021.01.01

workflow_dispatch:
inputs:
version:
Expand All @@ -17,39 +19,39 @@ on:
default: 'YYYY.MINOR.MICRO'
env:
REPO_URL: ${{ github.repository }}

jobs:
build:
# to test a feature, change the repo name to your github id
if: github.repository_owner == 'tl-its-umich-edu' || github.event_name == 'workflow_dispatch'
if: github.repository_owner == 'pushyamig' || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
steps:

- name: Checkout code
uses: actions/checkout@v4

- name: Extract branch name
id: extract_branch
run: echo "BRANCH_NAME=$(basename ${{ github.ref }})" >> $GITHUB_ENV

- name: build Docker image
run: |
docker build -f dockerfiles/Dockerfile.prod . --tag ghcr.io/${{ env.REPO_URL }}:${BRANCH_NAME}
docker build -f Dockerfile . --tag ghcr.io/${{ env.REPO_URL }}:${BRANCH_NAME}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Push Docker image to GitHub Container Registry
run: |
docker push ghcr.io/${{ env.REPO_URL }}:${BRANCH_NAME}
release:
# Making sure that release only runs for tag pushes
if: startsWith(github.ref, 'refs/tags/')'
if: startsWith(github.ref, 'refs/tags/')
needs: build # This ensures the build job finishes successfully before starting this job
runs-on: ubuntu-latest
steps:
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ venv/
ENV/
env.bak/
venv.bak/
venv_*

# Spyder project settings
.spyderproject
Expand Down Expand Up @@ -260,6 +261,7 @@ dist

# Stores VSCode versions used for testing VSCode extensions
.vscode-test
.history

# yarn v2
.yarn/cache
Expand Down
36 changes: 27 additions & 9 deletions dockerfiles/Dockerfile.prod → Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,35 @@ RUN npm install

RUN npm run build:frontend

# main stage

FROM python:3.10-slim-bookworm AS main
FROM python:3.10-slim

# NOTE: requirements.txt not likely to change between dev builds
COPY requirements.txt .
RUN apt-get update && \
apt-get install -y --no-install-recommends \
build-essential default-libmysqlclient-dev netcat-openbsd vim-tiny jq python3-dev git supervisor curl && \
build-essential \
netcat-openbsd \
vim-tiny \
jq \
python3-dev \
git \
supervisor \
curl \
pkg-config && \
apt-get upgrade -y && \
apt-get clean -y && \
rm -rf /var/lib/apt/lists/*

COPY requirements.txt .
# Install MariaDB from the mariadb repository rather than using Debians
# https://mariadb.com/kb/en/mariadb-package-repository-setup-and-usage/
RUN curl -LsS https://r.mariadb.com/downloads/mariadb_repo_setup | bash && \
apt install -y --no-install-recommends libmariadb-dev

RUN pip install --no-cache-dir -r requirements.txt

RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && \
apt install -y nodejs

WORKDIR /code

# Copy only what is needed into /code/
Expand All @@ -31,18 +46,21 @@ COPY manage.py start_backend.sh ./

COPY --from=node-build /build/bundles ./frontend/bundles
COPY --from=node-build /build/webpack-stats.json ./frontend/
COPY --from=node-build /build/node_modules ./frontend/node_modules


# Collect the static files in the backend
RUN python manage.py collectstatic --verbosity 0

# Sets the local timezone of the docker image
ARG TZ
ENV TZ ${TZ:-America/Detroit}
ENV RUN_FRONTEND ${RUN_FRONTEND:-false}
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

# EXPOSE port 5000 to allow communication to/from server
EXPOSE 5000

CMD ["/code/start_backend.sh"]
# NOTE: project files likely to change between dev builds
COPY . .

# Done!
CMD ["/usr/bin/supervisord", "-c", "/code/deploy/supervisor_docker.conf"]
# done!
36 changes: 0 additions & 36 deletions docker-compose-openshift-test.yml

This file was deleted.

2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ services:
web:
build:
context: .
dockerfile: dockerfiles/Dockerfile
dockerfile: Dockerfile
args:
TZ: ${TZ}
volumes:
Expand Down
48 changes: 0 additions & 48 deletions dockerfiles/Dockerfile

This file was deleted.

0 comments on commit 4574378

Please sign in to comment.