Skip to content

Commit

Permalink
docker entrypoint & IAAS readme
Browse files Browse the repository at this point in the history
  • Loading branch information
PabloNicolla committed Aug 4, 2024
1 parent 0f46d90 commit d70c9fc
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
7 changes: 3 additions & 4 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ RUN pip install --no-cache /wheels/*

COPY . .

RUN chmod +x entrypoint.sh

RUN chown -R myuser:myuser /app

USER myuser
Expand All @@ -73,7 +75,4 @@ EXPOSE 8000
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
CMD curl -f http://localhost:8000/health/ || exit 1

# RUN python manage.py makemigrations
# RUN python manage.py migrate

CMD ["daphne", "-b", "0.0.0.0", "-p", "8000", "core.asgi:application"]
ENTRYPOINT ["/app/entrypoint.sh"]
15 changes: 15 additions & 0 deletions backend/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/sh

set -e

# Check if the necessary environment variables are set
if [ -n "$POSTGRES_DB" ] && [ -n "$POSTGRES_USER" ] && [ -n "$POSTGRES_PASSWORD" ] && [ -n "$POSTGRES_HOST" ] && [ -n "$POSTGRES_PORT" ]; then
echo "Environment variables are set. Running migrations..."
python manage.py makemigrations
python manage.py migrate
else
echo "Environment variables are not set. Skipping migrations..."
fi

# Start Daphne server
exec daphne -b 0.0.0.0 -p 8000 core.asgi:application
9 changes: 9 additions & 0 deletions terraform/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ add your variables and follow the next step
> [!IMPORTANT]
> The first time you run the `terraform apply` it will fail. Just follow the instructions.
> [!IMPORTANT]
> Make sure you are logged into Azure by running `az login`
```
terraform init
terraform plan
Expand Down Expand Up @@ -51,6 +54,12 @@ Re-run terraform
terraform apply
```

### Check container logs

```
az container logs --resource-group myDjangoApp-rg --name mydjangoapplication
```

## SHUTDOWN deployment

```
Expand Down

0 comments on commit d70c9fc

Please sign in to comment.