-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #50 from mrsarm/master
Push latest changes to 4.2 branch
- Loading branch information
Showing
19 changed files
with
221 additions
and
232 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
name: Docker Image CI | ||
|
||
on: [push] | ||
|
||
jobs: | ||
|
||
build-test-release: | ||
name: Build, Test and Release | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Login to Docker Hub | ||
uses: docker/login-action@v3 | ||
if: ${{ env.DOCKERHUB_TOKEN }} | ||
with: | ||
username: ${{ vars.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
env: | ||
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
- name: Install pose | ||
run: | | ||
wget https://github.com/mrsarm/pose/releases/download/0.4.0/pose-0.4.0-x86_64-unknown-linux-gnu.tar.gz -O - \ | ||
| tar -xz | ||
- name: Define $TAG variable | ||
run: echo "TAG=$(./pose slug $GITHUB_REF_NAME)" >> "$GITHUB_ENV" | ||
- name: Print tag and image names | ||
run: | | ||
echo "- TAG --> $TAG" | ||
echo "- IMAGE --> mrsarm/django-coleman:$TAG" | ||
- name: Build the Docker image | ||
run: ./docker-build.sh $TAG | ||
|
||
- name: Run tests | ||
run: docker run --rm -e PROCESS_TYPE=test --name django-coleman "mrsarm/django-coleman:$TAG" | ||
|
||
- name: Release Docker image | ||
if: ${{ env.DOCKERHUB_TOKEN }} | ||
run: docker push "mrsarm/django-coleman:$TAG" | ||
env: | ||
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
- name: Get compose.yaml | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
./pose get -H "Authorization: token $GITHUB_TOKEN" \ | ||
"https://raw.githubusercontent.com/mrsarm/dcoleman-e2e/$TAG/compose.yaml" "$TAG:main" | ||
- name: Get .env.example | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
./pose get -H "Authorization: token $GITHUB_TOKEN" \ | ||
"https://raw.githubusercontent.com/mrsarm/dcoleman-e2e/$TAG/.env.example" "$TAG:main" | ||
- name: Setup environment variables | ||
run: cp .env.example .env | ||
|
||
- name: Build compose file for CI | ||
run: | | ||
./pose --no-docker config --tag $TAG --tag-filter regex=mrsarm/ --progress -o ci.yaml | ||
- name: Pull images | ||
run: docker compose -f ci.yaml pull | ||
&& docker compose -f ci.yaml pull dcoleman-e2e # services with profiles are not pulled by default | ||
|
||
- name: Run e2e tests | ||
run: docker compose -f ci.yaml run dcoleman-e2e | ||
|
||
- name: Tag "latest" | ||
if: ${{ env.DOCKERHUB_TOKEN && github.ref == 'refs/heads/master' }} | ||
run: docker tag "mrsarm/django-coleman:$TAG" mrsarm/django-coleman:latest | ||
env: | ||
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} | ||
- name: Release "latest" | ||
if: ${{ env.DOCKERHUB_TOKEN && github.ref == 'refs/heads/master' }} | ||
run: docker push mrsarm/django-coleman:latest | ||
env: | ||
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,3 +39,5 @@ venv*/ | |
|
||
/htmlcov | ||
/.coverage | ||
|
||
ci*.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
FROM python:3.11-slim | ||
FROM python:3.11-slim-bookworm | ||
LABEL maintainer="Mariano Ruiz <[email protected]>" | ||
|
||
ENV CXXFLAGS="-mtune=intel -Os -pipe" \ | ||
|
@@ -76,4 +76,7 @@ RUN honcho start collectstatic compilemessages \ | |
|
||
USER worker | ||
|
||
HEALTHCHECK --interval=20s --timeout=3s \ | ||
CMD curl -f http://localhost:8000/health/?format=json || exit 1 | ||
|
||
CMD ["sh", "-c", "exec honcho start --no-prefix $PROCESS_TYPE"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,8 @@ Features | |
partner (customer, provider...), description, responsible of the task, priority... | ||
* Each task may have items: sub-tasks to be done. | ||
* The built-in Django *Authentication and Authorization* system | ||
to manage users and groups, login, etc. | ||
to manage users and groups, login, etc, and optionally SSO with Google | ||
within the Admin (`django-google-sso <https://github.com/megalus/django-google-sso>`_). | ||
* Module `django-adminfilters <https://github.com/mrsarm/django-adminfilters>`_ | ||
that allows multiselection searches. | ||
* Send emails when a task is created. | ||
|
@@ -28,6 +29,11 @@ Features | |
* Pytest with some tests as example and code coverage reports configured. | ||
* Docker and Docker Compose configurations (images published in | ||
`Docker Hub <https://hub.docker.com/r/mrsarm/django-coleman>`_). | ||
* CI environment, and E2E tests written with Playwright: | ||
`dcoleman-e2e <https://github.com/mrsarm/dcoleman-e2e>`_. CI is executed with | ||
GitHub Actions, and executed on each push in this project, | ||
the viewer repo, or the E2E repo itself. The task also releases the image | ||
in the Docker Registry. | ||
* Ready to use "production" configurations as reference. | ||
|
||
.. image:: docs/source/_static/img/django-coleman.png | ||
|
@@ -39,7 +45,7 @@ Requirements | |
|
||
Docker, or: | ||
|
||
* Python 3.8+ (tested with Python 3.8 and 3.11). | ||
* Python 3.10+ (tested with 3.11). | ||
* Django 4.2 LTS and other dependencies declared in | ||
the ``requirements.txt`` file (use virtual environments or containers!). | ||
* A Django compatible database like PostgreSQL (by default uses | ||
|
@@ -117,21 +123,24 @@ Docker | |
A reference `<Dockerfile>`_ is provided, and the image published | ||
in `Docker Hub <https://hub.docker.com/r/mrsarm/django-coleman>`_. | ||
|
||
Also `<compose.yml>`_ and `<.env.example>`_ files are provided, you can run | ||
all from here, Django Coleman, the viewer app and Postgres. | ||
Also ``compose.yaml`` and ``.env.example`` files are provided in the | ||
`dcoleman-e2e <https://github.com/mrsarm/dcoleman-e2e>`_ project, you | ||
can run all from there, Django Coleman, the | ||
`viewer <https://github.com/mrsarm/tornado-dcoleman-mtasks-viewer>`_ app | ||
and Postgres, and the E2E tests. | ||
|
||
First, copy the ``.env.example`` file as ``.env`` file, and edit whatever | ||
value you want to:: | ||
First, copy the ``.env.example`` file as ``.env`` files from the E2E repo, | ||
and edit whatever value you want to:: | ||
|
||
$ cp .env.example .env | ||
$ cp ../dcoleman-e2e/.env.example .env | ||
|
||
Then before run for the first time the containers, you have to either | ||
download the images from Docker Hub or build them from the source code. To | ||
build the images from the source code, execute:: | ||
|
||
$ docker compose build | ||
$ ./docker-build.sh | ||
|
||
Or to get the images from Docker Hub, execute:: | ||
Or to get the images from Docker Hub, execute from the dcoleman-e2e repo:: | ||
|
||
$ docker compose pull | ||
|
||
|
@@ -168,7 +177,7 @@ to the Postgres container so even executing ``docker compose down`` | |
won't delete the data, but if you want to start from scratch:: | ||
|
||
$ docker compose down | ||
$ docker volume rm pg-coleman_data | ||
$ docker volume rm django-coleman_data | ||
|
||
Add changes in the code | ||
^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
@@ -178,7 +187,7 @@ When adding changes in the code, the image needs to be updated:: | |
$ docker compose build | ||
|
||
Then run again. A script ``docker-build.sh`` with more advance | ||
features and without using docker-compose is also provided | ||
features and without using docker compose is also provided | ||
to re-build the image. | ||
|
||
|
||
|
@@ -192,10 +201,11 @@ set *debug* options to false:: | |
$ DEBUG=False LANGUAGE_CODE=es-ar python3 manage.py runserver | ||
|
||
Also in development environments an ``.env`` file can be used to setup | ||
the environment variables easily, checkout the `<.env.example>`_ as example. | ||
the environment variables easily, checkout the | ||
`.env.example <https://github.com/mrsarm/dcoleman-e2e/blob/main/.env.example>`_ as example. | ||
You can copy the example file and edit the variables you want to change:: | ||
|
||
$ cp .env.example .env | ||
$ cp ../dcoleman-e2e/.env.example .env | ||
$ vi .env | ||
|
||
Some available settings: | ||
|
@@ -300,6 +310,6 @@ About | |
|
||
**Project**: https://github.com/mrsarm/django-coleman | ||
|
||
**Authors**: (2017-2023) Mariano Ruiz <[email protected]> | ||
**Authors**: (2017-2024) Mariano Ruiz <[email protected]> | ||
|
||
**License**: AGPL-v3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.