Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I322 gh actions #331

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions .github/workflows/build_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Build/Release

on:
push:
# takes muliple branch names
branches:
- main
- '[0-9][0-9][0-9][0-9].[0-9][0-9].*' # 2021.01.x
tags:
- '[0-9][0-9][0-9][0-9].[0-9][0-9].[0-9][0-9]' # 2021.01.01

workflow_dispatch:
inputs:
version:
description: 'Version'
required: true
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'
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 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/')
needs: build # This ensures the build job finishes successfully before starting this job
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Draft Release
id: create_release
uses: softprops/action-gh-release@v2
with:
draft: true
prerelease: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ venv/
ENV/
env.bak/
venv.bak/
venv_*

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

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

# yarn v2
.yarn/cache
Expand Down
34 changes: 24 additions & 10 deletions dockerfiles/Dockerfile → Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
# FROM directive instructing base image to build upon
# This could be used as a base instead:
# https://hub.docker.com/r/nikolaik/python-nodejs
# node-build stage

FROM node:20-slim AS node-build
WORKDIR /build/

COPY frontend .
RUN npm install

RUN npm run build:frontend

FROM python:3.10-slim

# NOTE: requirements.txt not likely to change between dev builds
Expand All @@ -27,19 +34,26 @@ apt install -y --no-install-recommends libmariadb-dev

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

WORKDIR /code/frontend

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

COPY /frontend/package*.json /code/frontend
RUN npm install
apt install -y nodejs

WORKDIR /code

# Copy only what is needed into /code/
COPY backend ./backend
COPY templates ./templates
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



# 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
Expand All @@ -49,4 +63,4 @@ EXPOSE 5000
COPY . .

CMD ["/usr/bin/supervisord", "-c", "/code/deploy/supervisor_docker.conf"]
# done!
# done!
2 changes: 1 addition & 1 deletion deploy/supervisor_docker.conf
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ startsecs=5
startretries=2

[program:frontend]
command=npm run watch
command=bash -c "if [ \"$RUN_FRONTEND\" = \"true\" ]; then npm run watch; else tail -f /dev/null; fi"
directory=/code/frontend
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
Expand Down
36 changes: 0 additions & 36 deletions docker-compose-openshift-test.yml

This file was deleted.

3 changes: 2 additions & 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 All @@ -35,6 +35,7 @@ services:
- .env
environment:
- DEBUG=True
- RUN_FRONTEND=true
redis:
image: redis:7
volumes:
Expand Down
53 changes: 0 additions & 53 deletions dockerfiles/Dockerfile.openshift

This file was deleted.