From 22eda67eae5893cc26245f1d74e3691bcceb082b Mon Sep 17 00:00:00 2001 From: Adora Date: Mon, 24 Jun 2024 13:49:18 -0600 Subject: [PATCH] Fix #3 Configuration of dockerfile for deploy --- .dockerignore | 4 +++ Dockerfile | 14 ++++++++++ README.md | 8 ++++++ environment/.env.production | 6 ++++ myFacegram/settings_production.py | 1 + ...thday_alter_profile_birthmonth_and_more.py | 28 +++++++++++++++++++ 6 files changed, 61 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 users/migrations/0014_alter_profile_birthday_alter_profile_birthmonth_and_more.py diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..1a2bd6e --- /dev/null +++ b/.dockerignore @@ -0,0 +1,4 @@ +.venv +media +static +environment/* \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..41187e8 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,14 @@ +FROM python:3.12.4 + +WORKDIR /app + +COPY . . + +RUN python -m pip install --user pipx +RUN python -m pipx ensurepath +RUN python -m pipx install poetry +RUN python -m pipx run poetry install + +EXPOSE 8000 +# CMD sh +CMD python -m pipx run poetry run daphne myFacegram.asgi:application -b 0.0.0.0 -p 8000 diff --git a/README.md b/README.md index 883e286..761eb82 100644 --- a/README.md +++ b/README.md @@ -34,3 +34,11 @@ pipx uninstall poetry ``` ### In initialized proyects +```sh +poetry init +``` + +## Docker +```sh +docker run -dti -p8000:8000 --name my-facegram --env-file ./environment/.env.production poetry-django +``` \ No newline at end of file diff --git a/environment/.env.production b/environment/.env.production index e69de29..6a39eb1 100644 --- a/environment/.env.production +++ b/environment/.env.production @@ -0,0 +1,6 @@ +SECRET_KEY=$SECRET_KEY +AWS_ACCOUNT_ID=$AWS_ACCOUNT_ID +AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID +AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY +AWS_STORAGE_BUCKET_NAME=$AWS_STORAGE_BUCKET_NAME +PROD_HOST=$PROD_HOST \ No newline at end of file diff --git a/myFacegram/settings_production.py b/myFacegram/settings_production.py index d099108..5245173 100644 --- a/myFacegram/settings_production.py +++ b/myFacegram/settings_production.py @@ -30,6 +30,7 @@ ALLOWED_HOSTS = [ '127.0.0.1', 'localhost', + os.environ["PROD_HOST"] ] diff --git a/users/migrations/0014_alter_profile_birthday_alter_profile_birthmonth_and_more.py b/users/migrations/0014_alter_profile_birthday_alter_profile_birthmonth_and_more.py new file mode 100644 index 0000000..9c0393e --- /dev/null +++ b/users/migrations/0014_alter_profile_birthday_alter_profile_birthmonth_and_more.py @@ -0,0 +1,28 @@ +# Generated by Django 5.0.6 on 2024-06-24 18:32 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('users', '0013_auto_20201026_1925'), + ] + + operations = [ + migrations.AlterField( + model_name='profile', + name='birthday', + field=models.IntegerField(blank=True, default='0', unique_for_date=True), + ), + migrations.AlterField( + model_name='profile', + name='birthmonth', + field=models.IntegerField(blank=True, default='0', unique_for_month=True), + ), + migrations.AlterField( + model_name='profile', + name='birthyear', + field=models.IntegerField(blank=True, default='0', unique_for_year=True), + ), + ]