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

fix the local docker build #38

Merged
merged 1 commit into from
Sep 20, 2024
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
19 changes: 10 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -348,19 +348,19 @@ SENDGRID_API_KEY=FAKE
[email protected]
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=<<POSTGRES_USER in .envs/.local/.postgres>>`
* 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=<<POSTGRES_USER in .envs/.local/.postgres>>`
* 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).

</details>
Expand All @@ -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`


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
title="click to pause/unpause participations, double click to edit more">
<h1 class="text-center"
title="{{meet_slug}}">
{{report_title|linebreaks}}
{{report_title|linebreaksbr}}
</h1>
<div class="flex-justify-between border-bottom">
<div></div>
Expand Down
9 changes: 5 additions & 4 deletions compose/local/django/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -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/*

Expand Down
8 changes: 4 additions & 4 deletions compose/local/docs/Dockerfile
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ services:
- ./config:/app/config:z
- ./attendees:/app/attendees:z
ports:
- "7000:7000"
- "7001:7000"
command: /start-docs

mailhog:
Expand Down
2 changes: 1 addition & 1 deletion requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading