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

Create a build process #133

Merged
merged 2 commits into from
Dec 27, 2023
Merged
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
20 changes: 20 additions & 0 deletions .github/workflows/build-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Build and push image to registry

on:
push:
branches:
- main
tags:
- v*

jobs:
build:
uses: code4romania/.github/.github/workflows/build-push-image.yml@main
with:
images: ghcr.io/code4romania/redirectioneaza
registry: ghcr.io
context: ./
dockerfile: ./docker/dockerfiles/Dockerfile
secrets:
username: ${{ github.actor }}
token: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ upd-sqlite: ## run the project with sqlite in detached mod
docker compose --profile sqlite3 up -d --build

up-mysql: ## run the project with mysql
docker compose --profile mysql up --build
docker compose --profile mysql up --build``

upd-mysql: ## run the project with mysql in detached mode
docker compose --profile mysql up -d --build
Expand Down
20 changes: 20 additions & 0 deletions backend/requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ frozenlist==1.4.1
# via
# aiohttp
# aiosignal
gevent==23.9.1
# via -r requirements.txt
greenlet==3.0.3
# via
# -r requirements.txt
# gevent
gunicorn==21.2.0
# via -r requirements.txt
idna==3.6
# via yarl
jinja2==3.1.2
Expand All @@ -69,8 +77,10 @@ mypy-extensions==1.0.0
# via black
packaging==23.2
# via
# -r requirements.txt
# black
# build
# gunicorn
pathspec==0.12.1
# via black
pip-tools==7.3.0
Expand Down Expand Up @@ -124,8 +134,18 @@ wcwidth==0.2.12
# blessed
wheel==0.42.0
# via pip-tools
whitenoise==6.6.0
# via -r requirements.txt
yarl==1.9.4
# via aiohttp
zope-event==5.0
# via
# -r requirements.txt
# gevent
zope-interface==6.1
# via
# -r requirements.txt
# gevent

# The following packages are considered to be unsafe in a requirements file:
# pip
Expand Down
7 changes: 7 additions & 0 deletions backend/requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,10 @@ jinja2~=3.1.2

# GeoIP support
python-geoip-geolite2==2015.303

# web server
gevent~=23.9.1
gunicorn~=21.2.0

# file storage
whitenoise~=6.6.0
17 changes: 17 additions & 0 deletions backend/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,18 @@ django-picklefield==3.1
# via django-q2
django-q2==1.6.1
# via -r requirements.in
gevent==23.9.1
# via -r requirements.in
greenlet==3.0.3
# via gevent
gunicorn==21.2.0
# via -r requirements.in
jinja2==3.1.2
# via -r requirements.in
markupsafe==2.1.3
# via jinja2
packaging==23.2
# via gunicorn
psutil==5.9.7
# via -r requirements.in
pycparser==2.21
Expand Down Expand Up @@ -60,3 +68,12 @@ urllib3==2.1.0
# via sentry-sdk
wcwidth==0.2.12
# via blessed
whitenoise==6.6.0
# via -r requirements.in
zope-event==5.0
# via gevent
zope-interface==6.1
# via gevent

# The following packages are considered to be unsafe in a requirements file:
# setuptools
12 changes: 6 additions & 6 deletions docker/dockerfiles/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
FROM node:18.17.1-bookworm-slim as frontend

WORKDIR /var/www/redirect/frontend

COPY ./frontend/ .
WORKDIR /var/www/redirect/build
COPY ./backend/ .

# install the frontend libraries:
RUN npm ci --no-audit --ignore-scripts && \
npm run prod
RUN npm install -g npm bower && \
bower install --allow-root --config.interactive=false

FROM python:3.11.7-slim-bookworm as backend

Expand All @@ -25,6 +24,7 @@ ENV PATH="${VIRTUAL_ENV}/bin:${PATH}"

WORKDIR /build
COPY ./backend/requirements.txt .

RUN python3 -m pip install --upgrade pip setuptools && \
python3 -m pip install -r ./requirements.txt

Expand Down Expand Up @@ -74,7 +74,7 @@ ENV PATH="${VIRTUAL_ENV}/bin:${PATH}"
COPY --from=backend "${VIRTUAL_ENV}" "${VIRTUAL_ENV}"
COPY ./backend/ /var/www/redirect/backend/

COPY --from=frontend /var/www/redirect/frontend/dist/ /var/www/redirect/frontend/dist/
COPY --from=frontend /var/www/redirect/build/bower_components/ /var/www/redirect/backend/bower_components/

# activate the virtualenv:
RUN . "${VIRTUAL_ENV}/bin/activate"
Expand Down
Loading