From bb680c576c2cb7a0321a621072a5852b5b12af8e Mon Sep 17 00:00:00 2001 From: Jack Date: Fri, 20 Sep 2024 09:28:59 -0700 Subject: [PATCH] fix the local docker build --- README.md | 19 ++++++++++--------- .../attendingmeet_report_list_view.html | 2 +- compose/local/django/Dockerfile | 9 +++++---- compose/local/docs/Dockerfile | 8 ++++---- local.yml | 2 +- requirements/base.txt | 2 +- 6 files changed, 22 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index ec681a5f..24ecc34c 100644 --- a/README.md +++ b/README.md @@ -348,19 +348,19 @@ SENDGRID_API_KEY=FAKE DJANGO_DEFAULT_FROM_EMAIL=fake@email.com DJANGO_SECRET_KEY=your_django_secret_key ``` -* build and start the local machine by `docker-compose -f local.yml build && docker-compose -f local.yml up -d`. If there's error about `docker-credential-desktop`, change credsStore to credStore in `~/.docker/config.json` -* create migration files by `docker-compose -f local.yml run --rm django python manage.py makemigrations` -* migrate db by `docker-compose -f local.yml run --rm django python manage.py migrate` -* upadte content types after migration by `docker-compose -f local.yml run django python manage.py update_content_types` -* create 2 superusers by `docker-compose -f local.yml run --rm django python manage.py createsuperuser` -* import the seed data by `docker-compose -f local.yml run django python manage.py loaddata fixtures/db_seed`, data were created by: +* build and start the local machine by `docker compose -f local.yml build && docker compose -f local.yml up -d`. If there's error about `docker-credential-desktop`, change credsStore to credStore in `~/.docker/config.json` +* create migration files by `docker compose -f local.yml run --rm django python manage.py makemigrations` +* migrate db by `docker compose -f local.yml run --rm django python manage.py migrate` +* upadte content types after migration by `docker compose -f local.yml run django python manage.py update_content_types` +* create 2 superusers by `docker compose -f local.yml run --rm django python manage.py createsuperuser` +* import the seed data by `docker compose -f local.yml run django python manage.py loaddata fixtures/db_seed`, data were created by: ``` - docker-compose -f local.yml run django python manage.py dumpdata -e users.user -e admin.logentry -e sessions.session -e contenttypes.contenttype -e sites.site -e account.emailaddress -e account.emailconfirmation -e socialaccount.socialtoken -e auth.permission -e pghistory.context -e pghistory.aggregateevent -e users.userhistory -e users.menushistory -e users.menuauthgroupshistory -e users.groupshistory -e users.grouppermissionshistory -e users.usergroupshistory -e users.userpermissionshistory -e users.emailaddresshistory -e users.emailconfirmationhistory -e whereabouts.organizationshistory -e whereabouts.divisionshistory -e whereabouts.placeshistory -e whereabouts.campuseshistory -e whereabouts.propertieshistory -e whereabouts.suiteshistory -e whereabouts.roomshistory -e whereabouts.countryhistory -e whereabouts.statehistory -e whereabouts.localityhistory -e whereabouts.addresshistory -e persons.categorieshistory -e persons.noteshistory -e persons.pastshistory -e persons.folkshistory -e persons.attendeeshistory -e persons.folkattendeeshistory -e persons.relationshistory -e persons.registrationshistory -e persons.attendingshistory -e persons.attendingmeetshistory -e occasions.assemblieshistory -e occasions.attendanceshistory -e occasions.charactershistory -e occasions.gatheringshistory -e occasions.meetshistory -e occasions.messagetemplateshistory -e occasions.priceshistory -e occasions.teamshistory -e occasions.calendarhistory -e occasions.calendarrelationhistory -e occasions.eventhistory -e occasions.eventrelationhistory -e occasions.occurrencehistory -e occasions.rulehistory -e occasions.periodictaskhistory -e occasions.crontabschedulehistory -e occasions.intervalschedulehistory -e users.permissionshistory -e users.GroupPermissionProxy -e users.UserGroupProxy -e users.UserPermissionProxy --indent 2 > fixtures/db_seed2.json + docker compose -f local.yml run django python manage.py dumpdata -e users.user -e admin.logentry -e sessions.session -e contenttypes.contenttype -e sites.site -e account.emailaddress -e account.emailconfirmation -e socialaccount.socialtoken -e auth.permission -e pghistory.context -e pghistory.aggregateevent -e users.userhistory -e users.menushistory -e users.menuauthgroupshistory -e users.groupshistory -e users.grouppermissionshistory -e users.usergroupshistory -e users.userpermissionshistory -e users.emailaddresshistory -e users.emailconfirmationhistory -e whereabouts.organizationshistory -e whereabouts.divisionshistory -e whereabouts.placeshistory -e whereabouts.campuseshistory -e whereabouts.propertieshistory -e whereabouts.suiteshistory -e whereabouts.roomshistory -e whereabouts.countryhistory -e whereabouts.statehistory -e whereabouts.localityhistory -e whereabouts.addresshistory -e persons.categorieshistory -e persons.noteshistory -e persons.pastshistory -e persons.folkshistory -e persons.attendeeshistory -e persons.folkattendeeshistory -e persons.relationshistory -e persons.registrationshistory -e persons.attendingshistory -e persons.attendingmeetshistory -e occasions.assemblieshistory -e occasions.attendanceshistory -e occasions.charactershistory -e occasions.gatheringshistory -e occasions.meetshistory -e occasions.messagetemplateshistory -e occasions.priceshistory -e occasions.teamshistory -e occasions.calendarhistory -e occasions.calendarrelationhistory -e occasions.eventhistory -e occasions.eventrelationhistory -e occasions.occurrencehistory -e occasions.rulehistory -e occasions.periodictaskhistory -e occasions.crontabschedulehistory -e occasions.intervalschedulehistory -e users.permissionshistory -e users.GroupPermissionProxy -e users.UserGroupProxy -e users.UserPermissionProxy --indent 2 > fixtures/db_seed2.json ``` * go to Django admin to add the first organization and all groups to the first user (superuser) at http://192.168.99.100:8008/admin123/users/user/ * use browser to open http://192.168.99.100:8008/ and http://192.168.99.100:8025/ -* Enter postgres db console by `docker-compose -f local.yml exec postgres psql -d attendees --username=<>` -* Enter Django console by `docker-compose -f local.yml run django python manage.py shell_plus` +* Enter postgres db console by `docker compose -f local.yml exec postgres psql -d attendees --username=<>` +* Enter Django console by `docker compose -f local.yml run django python manage.py shell_plus` * remote debug in PyCharm for docker, please check [django cookie doc](https://github.com/pydanny/cookiecutter-django/blob/master/{{cookiecutter.project_slug}}/docs/pycharm/configuration.rst). @@ -382,6 +382,7 @@ EMAIL_HOST=sendgrid * In Docker Desktop Settings, please ensure both "Use Virtualization framework" and "Use Rosetta for x86_64/amd64 emulation on Apple Silicon" options in enabled. * build and start the Debian based local machine by `docker compose -f local.yml build && docker compose -f local.yml up -d`, your site will be at http://0.0.0.0:8008/ * to see django log: `docker compose -f local.yml logs django` +* enter the Bash shell of running container `docker compose -f local.yml run django bash` * enter Redis-CLI by `docker exec -it redis redis-cli` diff --git a/attendees/templates/persons/attendingmeet_report_list_view.html b/attendees/templates/persons/attendingmeet_report_list_view.html index 1605564e..2dca47f4 100644 --- a/attendees/templates/persons/attendingmeet_report_list_view.html +++ b/attendees/templates/persons/attendingmeet_report_list_view.html @@ -32,7 +32,7 @@ title="click to pause/unpause participations, double click to edit more">

- {{report_title|linebreaks}} + {{report_title|linebreaksbr}}

diff --git a/compose/local/django/Dockerfile b/compose/local/django/Dockerfile index 92c69dd8..5aa7ffe0 100644 --- a/compose/local/django/Dockerfile +++ b/compose/local/django/Dockerfile @@ -1,10 +1,10 @@ -ARG PYTHON_VERSION=3.9-slim-bullseye +ARG PYTHON_VERSION=3.10-slim-bookworm # define an alias for the specfic python version used in this file. -FROM python:${PYTHON_VERSION} as python +FROM python:${PYTHON_VERSION} AS python # Python build stage -FROM python as python-build-stage +FROM python AS python-build-stage ARG BUILD_ENVIRONMENT=local # Install apt packages @@ -23,7 +23,7 @@ RUN pip wheel --wheel-dir /usr/src/app/wheels \ # Python 'run' stage -FROM python as python-run-stage +FROM python AS python-run-stage ARG BUILD_ENVIRONMENT=local ARG APP_HOME=/app @@ -41,6 +41,7 @@ RUN apt-get update && apt-get install --no-install-recommends -y \ # Translations dependencies gettext curl vim wget python3-dateutil git less gdal-bin libpango-1.0-0 libpangoft2-1.0-0 \ # cleaning up unused files + && apt-get purge -y fontconfig-config mysql-common \ && apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \ && rm -rf /var/lib/apt/lists/* diff --git a/compose/local/docs/Dockerfile b/compose/local/docs/Dockerfile index 97367e05..360213f0 100644 --- a/compose/local/docs/Dockerfile +++ b/compose/local/docs/Dockerfile @@ -1,11 +1,11 @@ -ARG PYTHON_VERSION=3.9-slim-bullseye +ARG PYTHON_VERSION=3.10-slim-bookworm # define an alias for the specfic python version used in this file. -FROM python:${PYTHON_VERSION} as python +FROM python:${PYTHON_VERSION} AS python # Python build stage -FROM python as python-build-stage +FROM python AS python-build-stage ENV PYTHONDONTWRITEBYTECODE 1 @@ -28,7 +28,7 @@ RUN pip wheel --no-cache-dir --no-deps --wheel-dir /usr/src/app/wheels \ # Python 'run' stage -FROM python as python-run-stage +FROM python AS python-run-stage ARG BUILD_ENVIRONMENT ENV PYTHONUNBUFFERED 1 diff --git a/local.yml b/local.yml index a6cbad83..e33e1f45 100644 --- a/local.yml +++ b/local.yml @@ -53,7 +53,7 @@ services: - ./config:/app/config:z - ./attendees:/app/attendees:z ports: - - "7000:7000" + - "7001:7000" command: /start-docs mailhog: diff --git a/requirements/base.txt b/requirements/base.txt index e5ca0475..ecd53067 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -12,7 +12,7 @@ flower==2.0.1 # https://github.com/mher/flower uvicorn[standard]==0.29.0 # https://github.com/encode/uvicorn psycopg2==2.9.9 # https://github.com/psycopg/psycopg2 unidecode==1.3.2 -opencc==1.1.3 ## https://github.com/BYVoid/OpenCC +opencc==1.1.8 ## https://github.com/BYVoid/OpenCC # opencc-python-reimplemented==0.1.6 ## https://github.com/yichen0831/opencc-python # django-address==0.2.5 # https://github.com/furious-luke/django-address -e git+https://github.com/xjlin0/django-address.git@address_extra_field_026#egg=django-address