Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare for staging deployment #45

Closed
wants to merge 47 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
5a512e2
Implement proxy and production deployment settings
dchiller Sep 28, 2023
f85398b
Add instructions for remote deployment
dchiller Sep 29, 2023
dfa4937
Add basic instrument gallery view
dchiller Sep 28, 2023
bae2dd1
Add pagination to instrument list view
dchiller Sep 28, 2023
f19483f
Add python formatting action
dchiller Sep 29, 2023
fa8e253
🆕 Initialize templates
yinanazhou Sep 22, 2023
09e1d18
🆕 Initialize css files
yinanazhou Sep 22, 2023
1d6c490
🆕 Create 404 page
yinanazhou Sep 22, 2023
d3cf892
🛠️ Set up base navbar & footer
yinanazhou Sep 23, 2023
6670e14
Add language button
yinanazhou Sep 25, 2023
16d0aa6
Minor style adjustment for base page
yinanazhou Sep 25, 2023
62ccb57
Init masonry for instruments
yinanazhou Sep 26, 2023
6ff387d
Adjust footer style
yinanazhou Sep 26, 2023
43affad
Add example content for sidebar
yinanazhou Sep 26, 2023
78ce4a3
Rename sidebar-block to info-block
yinanazhou Sep 26, 2023
93017a3
Adjust card style
yinanazhou Sep 26, 2023
7b6d49c
Remove redundant tag
yinanazhou Sep 27, 2023
3dccdb4
Adjust page layout
yinanazhou Sep 27, 2023
2152f86
Only display english names
yinanazhou Sep 27, 2023
ee0b654
Wrap masonry into js file
yinanazhou Sep 27, 2023
11c829c
Add pagination block
yinanazhou Sep 27, 2023
496c52b
Rename show-more collapse id
yinanazhou Sep 27, 2023
737e34c
Remove slice
yinanazhou Sep 28, 2023
a6de88d
Adjust page button style
yinanazhou Sep 28, 2023
bda76ba
Update pagination style & link
yinanazhou Sep 28, 2023
224bea1
Rename content-container to body-container
yinanazhou Sep 28, 2023
3b0cc57
♻️Update ImagesLoaded & Masonry
yinanazhou Sep 28, 2023
6587d0d
Add masonry display button
yinanazhou Sep 28, 2023
28e70d0
Add display switch functionality
yinanazhou Sep 29, 2023
3be8145
Adjust layout style
yinanazhou Sep 29, 2023
0fa5407
🪄 Add list view
yinanazhou Sep 29, 2023
b7abc58
Align image center
yinanazhou Oct 2, 2023
292b824
Remove padding
yinanazhou Oct 2, 2023
94671f6
Add standard view
yinanazhou Oct 2, 2023
3fdf089
Save display mode to local storage
yinanazhou Oct 2, 2023
b7218d4
Add home page
yinanazhou Oct 3, 2023
8b44345
Move base templates & static folder into VIM/
yinanazhou Oct 3, 2023
bc76efd
Add links to navbar
yinanazhou Oct 3, 2023
7ef09dd
Correct static files dirs
yinanazhou Oct 3, 2023
d77aff4
Add about page & include urls from main app
yinanazhou Oct 3, 2023
2ec981b
Add active indication & adjust navbar styles
yinanazhou Oct 4, 2023
d4bf1e3
Change uri to url in templates
dchiller Oct 4, 2023
569a789
Format code
dchiller Oct 5, 2023
70270f1
Add poetry for dependency management
dchiller Oct 4, 2023
d759e9f
Add documentation for development dependencies
dchiller Oct 5, 2023
eb7f28d
Merge branch 'develop' into prepare-for-staging-deployment
dchiller Oct 5, 2023
cd2ab24
Format settings.py
dchiller Oct 5, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
VERSION=0.1.0

DEVELOPMENT=false
HOST_NAME=vim.linkedmusic.ca

## DATABASE ##
POSTGRES_DB=virtual_instrument_museum
Expand Down
33 changes: 31 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ ping instrument names and facilitating cross-referencing of instruments across d

## Installation for Local Development

NOTE: VIM is not yet ready for deployment to a remote server. Use these steps for local testing and development only.
NOTE: These instructions are for local development only. Refer to the "Installation for Deployment" section for installation on a remote server.

VIM requires Docker Engine with Compose V2. VIM's Docker Compose configuration is written according to the Compose Specification.

After cloning this repository, set up a local `.env` file. Copy or rename the `.env.sample` file to `.env` and update it to include uncommented environment variables for database credentials `POSTGRES_USER` and `POSTGRES_PASSWORD`.
After cloning this repository, set up a local `.env` file. Copy or rename the `.env.sample` file to `.env` and update it to include uncommented environment variables for database credentials `POSTGRES_USER` and `POSTGRES_PASSWORD`. Verify the values of the `DEVELOPMENT` and `HOST_NAME` variables. For local development ONLY, these should be set to "true" and "localhost" respectively.

```console
> docker compose build
Expand All @@ -21,6 +21,35 @@ After cloning this repository, set up a local `.env` file. Copy or rename the `.

The django development server should now be available at `localhost:8000`.

### Debugging

When installed with `DEVELOPMENT=true` in the `.env` file, some additional modules are included in the application container that provide debugging tools: `django-extensions` and `django-debug-toolbar`. The development installation runs the `runserver_plus` (provided by `django-extensions`) command automatically, which provides an in-browser debug console when errors are raised in the application. `django-extensions` also provides additional tools potentitally useful for development; see the [module documentation](https://django-extensions.readthedocs.io/en/latest/command_extensions.html) for more. The debugging toolbar provided by `django-debug-toolbar` is shown when viewing the development server in the browser.

### Tools for Python Development

VIM uses `poetry` to manage python dependencies and a `poetry.lock` file to ensure reproducible builds in development and production. Dependencies can be found in the `pyproject.toml` file and are divided into three groups:

1. `main` - the core dependencies required by the application
2. `debug` - dependencies that provide tools for debugging, and that are installed in the application Docker container only during local development
3. `dev` - optional dependencies (eg. for code formatting, linting, type checking) that can be useful in the development environment, but are never used in the application container

It is not generally necessary to use `poetry` for development, except when adding additional dependencies.

## Installation for Deployment

VIM requires Docker Engine with Compose V2. Ensure that the remote server has these installed.

SSH into the server. After cloning the repository, set up a local `.env` file. Copy or rename the `.env.sample` file to `.env` and update it to include uncommented environment variables for database credentials `POSTGRES_USER` and `POSTGRES_PASSWORD`. Ensure that `POSTGRES_PASSWORD` is secure.

Ensure that the `DEVELOPMENT` variable is set to "false", and that `HOST_NAME` is set to the host name where the VIM instance will be served (for example, "vim.linkedmusic.ca" or "vim.staging.linkedmusic.ca").

Then, run

```bash
> docker compose build
> docker compose up -d
```

## Managing Database Migrations

Django automates changes to the database schema with migrations.
Expand Down
22 changes: 18 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
# Uses Compose Specification (https://github.com/compose-spec/compose-spec/blob/master/spec.md)
services:
app:
build: ./web-app
build:
context: .
dockerfile: ./web-app/Dockerfile
args:
- DEVELOPMENT=$DEVELOPMENT
container_name: vim-app
volumes:
- ./web-app/django:/virtual-instrument-museum/vim-app
Expand All @@ -12,8 +16,7 @@ services:
- POSTGRES_DB=${POSTGRES_DB}
- POSTGRES_USER=${POSTGRES_USER}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
ports:
- "8000:8000"
- HOST_NAME=${HOST_NAME}
command: /virtual-instrument-museum/django-startup.sh

postgres:
Expand All @@ -33,5 +36,16 @@ services:
start_period: 30s
restart: unless-stopped

nginx:
build: ./nginx
container_name: vim-nginx
restart: unless-stopped
environment:
- HOST_NAME=${HOST_NAME}
ports:
- "8000:80"
depends_on:
- app

networks:
vim-net:
vim-net:
3 changes: 3 additions & 0 deletions nginx/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM nginx:1.25.2
COPY ./nginx.conf /etc/nginx/nginx.conf
COPY ./vim.conf.template /etc/nginx/templates/vim.conf.template
16 changes: 16 additions & 0 deletions nginx/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
worker_processes 1;

user nginx nginx;
error_log /var/log/nginx/error.log warn; # piped to Docker log collector (see nginx Dockerfile)
pid /var/log/nginx/nginx.pid;

events {
accept_mutex off;
}

http {
include mime.types; # include bundled mime type mapping file
access_log /var/log/nginx/access.log combined; # piped to Docker log collector (see nginx Dockerfile)

include /etc/nginx/conf.d/vim.conf; # include virtual host configurations
}
25 changes: 25 additions & 0 deletions nginx/vim.conf.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
upstream vim-app {
# define the vim-app upstream server
server vim-app:8001 fail_timeout=0;
}

server {
# if no host match, close connection
listen 80 default_server;
return 444;
}


server {
listen 80;
client_max_body_size 4G;
server_name ${HOST_NAME};

location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; # pass client address to upstream server
proxy_set_header X-Forwarded-Proto $scheme; # pass scheme to upstream server
proxy_set_header Host $http_host; # pass host to upstream server

proxy_pass http://vim-app; # proxy request to vim-app upstream server
}
}
Loading