This project utilizes poetry, podman, docker-compose, and just for managing scripts, containers, and dependencies.
-
Install
podman
,docker-compose
, andjust
- Arch user might have to install additional packages for rootless podman. See here for more information.
-
Create a
.env
at least with the following content:DATABASE_HOST=sipam DATABASE_NAME=sipam SIPAM_DATABASE_USER_NAME=sipam SIPAM_DATABASE_USER_PASSWORD=<password>
-
Run
just up -d
(this will initially build the containers and start them) -
After the containers are up and running, run
just init-setup
(this will initialize the database and create a superuser)- You will be ask to create a superuser. This is the user you will use to login to the web interface of django.
- This step will also fill the database with some sample data. If you need more data just ask.
To see what commands are available, run just just
. This will list all available commands including a short description.
After starting the containers you should be able to access the vue frontend at http://localhost:3000 and the django backend at http://localhost:8000/api/v1/.
Note: Depending on your
container.dev-override.yml
you may need to define more environment variables in your.env
file.
If you want a UI for the database you can use pgadmin
. This gives you full access to the database. Follow the steps below to get it running.
-
If the container are already running, stop them with
just down
-
Add the following to your
container.dev-override.yml
:services: pgadmin: image: dpage/pgadmin4:7 environment: PGADMIN_DEFAULT_EMAIL: ${PGADMIN_DEFAULT_EMAIL:?err} PGADMIN_DEFAULT_PASSWORD: ${PGADMIN_DEFAULT_PASSWORD:?err} ports: - ${PGADMIN_PORT:-5050}:80 restart: unless-stopped depends_on: - postgres
-
Run
just up -d
(this will initially build the containers and start them)
This is only an example of how you can customize the compose file. This file also allows to override the default values of the compose.dev.yml
file.
IP Functions:
- Postgres: https://www.postgresql.org/docs/11/functions-net.html
- Netfields: https://github.com/jimfunk/django-postgresql-netfields
sudo -iu postgres
initdb -D /var/lib/postgres/data # you can edit this path as you like (only arch)
exit
systemctl start postgresql
systemctl enable postgresql # this is optional if you want to start it on boot.
sudo -iu postgres
createuser --interactive # <sipam> say no to everything it will be a dump database user.
psql
ALTER USER sipam CREATEDB; # For pytest
exit
createdb sipam -O sipam # first is database name second is username
psql
\password sipam # set the password from secret.py their two times
GRANT ALL PRIVILEGES ON DATABASE sipam TO sipam;
\q
exit
- This project uses poetry for dependency management.
- Setup is as easy as running
poetry install
- New packages can be added with
poetry add <package>
- If the package is only required for development purposes use
poetry add --dev <package>
- Setup is as easy as running
- create a file
sipam/secret.py
add the variablePASSWORD="<password>
andHOST="<hostname>"
- If you have a local redis instance set the
REDIS_HOSTNAME
accordingly insipam/secret.py
. If you set it toNone
a dummy cache (aka. none) will be used.
For local development yarn serve
and the development Django server are sufficient.
To make life easier it is recommended to generate a superuser account for login.
This can be achieved.
# Activate the virtual-env shell
poetry shell
# Create a local superuser
python manage.py createsuperuser
$ Username: sipam_dev
$ Email address: [email protected]
$ Password:
$ Password (again):
$ Superuser created successfully.
This user can be used for local development. You can now login with this user from the Frontend or the Backend.