In order to run the application in docker compose you must follow these steps:
- Clone this repository:
git clone https://github.com/isaacte/WebProject
- Set
POSTGRES_USER
(User of the Postgres DB),POSTGRES_PASSWORD
(Password for the user) andPOSTGRES_DB
(Name of the dabase) on docker-compose.yaml. *This step is not required (but strongly recommended) as there are some default values declared. - Create a
.env
file in the root path of the folder containing the following information:
DEBUG=<0|1>
SECRET_KEY=<secret_key>
DJANGO_ALLOWED_HOSTS=<127.0.0.1, localhost, ...>
DATABASE_URL=<postgres://dbuser:dbpassword@dbhost:dbport/dbname>
The variables can be changed to configure the application as desired.
-
Execute the docker compose application (this will build the images if does not exist):
docker compose up
-
If you want to rebuild the images you can use the following command:
docker compose up --build
If you want to run some commands you can attach to the docker web
container or run it via docker compose exec as following: docker compose exec web <command>
In order to deploy the application in fly.io you must be registered and have the Fly CLI installed with the account logged in.
- Clone this repository:
git clone https://github.com/isaacte/WebProject
- Create a
.env
file in the root path of the folder containing the following information:
DEBUG=<0|1>
DJANGO_ALLOWED_HOSTS=<domain.fly.dev>
The variables can be changed to configure the application as desired.
*Fly.io will automatically deploy a Postgres DB and add the DATABASE_URL in the enviroment variable.
- Run
fly launch --copy-config --dockerfile Dockerfile --ignorefile .dockerignore
. - Follow the steps of the wizard that will ask you for the app name, a region to deploy, if you want to setup a Postgresql database now (Say yes), an Upstash Redis database now (Say no) and if you want to deploy now (Say yes).
- After the setup finishes anotate the
DATABASE_URL
andSECRET_KEY
for further usages` - After deploying you can deploy the application via
fly deploy
. - After deploying you can open the application via
fly open
. - After opening the application you should apply database migrations and collect statics. Run:
fly ssh console -C "python code/manage.py migrate"
to apply the migrations into the database andfly ssh console -C "python code/manage.py collectstatic"
to collect the static files.