Skip to content

Commit

Permalink
add default files for install
Browse files Browse the repository at this point in the history
  • Loading branch information
submarcos committed Jun 26, 2024
1 parent 5135a14 commit 82e7be4
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 7 deletions.
3 changes: 2 additions & 1 deletion .docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
apt-get -qq install -y nodejs

COPY .docker/entrypoint.sh /usr/local/bin/entrypoint.sh
COPY .docker/update.sh /usr/local/bin/rga-update

ENTRYPOINT ["/bin/sh", "-e", "/usr/local/bin/entrypoint.sh"]

Expand Down Expand Up @@ -97,7 +98,7 @@ RUN npm ci --no-audit --only=production

COPY --chown=ubuntu:ubuntu --from=build /app/venv /app/venv
COPY --chown=ubuntu:ubuntu --from=build /app/front-end/dist /app/front-end/dist
COPY --chown=ubuntu:ubuntu backend/project/ /app/backend
COPY --chown=ubuntu:ubuntu backend/project/ /app/backend/project
COPY --chown=ubuntu:ubuntu backend/manage.py /app/backend/manage.py

WORKDIR /app/backend
Expand Down
7 changes: 7 additions & 0 deletions .docker/update.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash

# Migrate database
python ./manage.py migrate --noinput

# Collect static files
python ./manage.py collectstatic --noinput
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,8 @@ Thumbs.db
/front-end/node_modules/
/front-end/.angular/cache/
/backend/public/
!/install/db.env
/install/app.env
/install/db.env
/install/public/static/
/install/public/media/

2 changes: 1 addition & 1 deletion backend/project/settings/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False

ALLOWED_HOSTS = []
ALLOWED_HOSTS = os.getenv("SERVER_NAME", "").split(",")


# Application definition
Expand Down
2 changes: 2 additions & 0 deletions install/.env.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
VERSION=latest
NGINX_PORT=8080
24 changes: 24 additions & 0 deletions install/INSTALL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Standard install

- Unzip last release
- Copy app.env.dist to app.env
- Fill your timezone and your server name (domain used in your browser)
- Copy db.env.dist to db.env
- Fill your database name, user and password
- Init instance

```bash
docker compose run --rm back rga-update
```

- Create a first super user

```bash
docker compose run --rm back ./manage.py createsuperuser
```

- Run instance

```bash
docker compose up
```
1 change: 1 addition & 0 deletions install/app.env.dist
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
SERVER_NAME=localhost
TZ=Europe/Paris
5 changes: 4 additions & 1 deletion install/conf/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ server {

client_max_body_size 200M;

location ~ ^/(api|admin|static|media)/ {
location ~ ^/(api|admin)/ {
proxy_pass http://django;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
Expand All @@ -33,5 +33,8 @@ server {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
7 changes: 4 additions & 3 deletions install/db.env.dist
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres
POSTGRES_DB=postgres
POSTGRES_USER=
POSTGRES_PASSWORD=
POSTGRES_DB=
POSTGRES_HOST=postgres
2 changes: 2 additions & 0 deletions install/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ services:

volumes:
- ./conf:/app/backend/conf
- ./public:/app/backend/public

user: ${UID}:${GID}

Expand All @@ -53,5 +54,6 @@ services:
volumes:
- ./public:/var/www/
- ./conf/nginx.conf:/etc/nginx/conf.d/default.conf

volumes:
postgres_data:

0 comments on commit 82e7be4

Please sign in to comment.