Workflow actions & dockerfile

This commit is contained in:
Corban-Lee Jones 2024-08-04 00:25:07 +01:00
parent 1a436c6eb6
commit 96a2b43122
2 changed files with 48 additions and 4 deletions

View File

@ -0,0 +1,42 @@
name: Build and Push Docker Image
on:
push:
branches:
- main
tags:
- '*'
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.11'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install bump2version
- name: Bump version
run: |
bump2version patch
- name: Build Docker image
run: |
docker build -t pyrss-website:${{ steps.bump-version.outputs.new_version }} .
- name: Push Docker image
run: |
docker tag pyrss-website:${{ steps.bump-version.outputs.new_version }} xordk/pyrss-website:${{ steps.bump-version.outputs.new_version }}
docker push xordk/pyrss-website:${{ steps.bump-version.outputs.new_version }}
env:
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}

View File

@ -1,18 +1,20 @@
FROM python:3.9
FROM python:3.11
# set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
COPY requirements.txt .
WORKDIR /app
COPY requirements.txt /app/
# install python dependencies
RUN pip install --upgrade pip
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
COPY . /app/
# running migrations
RUN python manage.py migrate
# gunicorn
CMD ["gunicorn", "--config", "gunicorn-cfg.py", "core.wsgi"]
# CMD ["gunicorn", "--config", "gunicorn-cfg.py", "core.wsgi"]