Skip to content

Commit

Permalink
Add README, commit docker-compose.yaml and nginx.conf.
Browse files Browse the repository at this point in the history
  • Loading branch information
ropable committed Nov 15, 2024
1 parent eda3b51 commit 45b05a0
Show file tree
Hide file tree
Showing 3 changed files with 178 additions and 0 deletions.
52 changes: 52 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# North West Shelf Flatback Turtles Conservation Program public website

This project contains project dependencies and custom elements for the DBCA
North West Shelf Flatback Turtles Conservation Program public website. The
website is developed using the Drupal content management system.

## Development

The project dependencies (including Drupal) are installed and managed using Composer.
Set up a local development environment like so:

1. Install and set up Composer and any local dependencies.
1. Clone the project locally.
1. Change into the project directory and install dependencies: `composer install`
1. Create a local configuration file at `web/sites/default/settings.php`
1. Develop and test the site as normal, taking care to commit any custom elements
under `web/` into the project repository (while avoiding to commit "generic" elements).

## Docker image

To build a new Docker image from the `Dockerfile`:

docker image build -t ghcr.io/dbca-wa/flatbacks-website .

## Docker Compose

Use the included Compose file to start the required services to serve the project.
Prerequisites:

1. Docker image is built (see above).
1. A local `settings.php` should be generated containing site configuration.
1. Local `.env.mysql` and `.env.flatbacks` files should be created, containing secrets.
1. Start services: `docker compose up`
1. After Docker volumes are generated, copy the contents of `web` and `web/sites/default/files`
into the relevant Docker volumes so that the Nginx container can serve those files.

`.env.mysql` example:

TZ=Australia/Perth
MARIADB_ROOT_PASSWORD=database_root_password

`.env.flatbacks` example:

TZ=Australia/Perth
SALT_HASH=LongSaltValue
DATABASE_NAME=database_name
DATABASE_USERNAME=database_username
DATABASE_PASSWORD=database_password
DATABASE_HOST=mysql11
DATABASE_PORT=3306
REDIS_HOST=redis
REDIS_PORT=6379
36 changes: 36 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
services:
mysql11:
image: "mariadb:11.4"
ports:
- "3306:3306"
env_file: ".env.mysql"
volumes:
- "mysql11_data:/var/lib/mysql"
flatbacks:
image: "ghcr.io/dbca-wa/flatbacks-website"
env_file: ".env.flatbacks"
volumes:
- "flatbacks_site:/opt/drupal/web:ro"
- "${PWD}/settings.php:/opt/drupal/web/sites/default/settings.php:ro"
- "flatbacks_files:/opt/drupal/web/sites/default/files"
nginx:
image: "nginxinc/nginx-unprivileged:stable-alpine"
ports:
- "8080:8080"
environment:
TZ: "Australia/Perth"
volumes:
- "${PWD}/nginx.conf:/etc/nginx/nginx.conf:ro"
- "flatbacks_site:/var/www/html:ro"
- "flatbacks_files:/var/www/html/sites/default/files:ro"
redis:
image: "redis:7.2-alpine"
ports:
- "6379:6379"
environment:
TZ: "Australia/Perth"

volumes:
mysql11_data:
flatbacks_site:
flatbacks_files:
90 changes: 90 additions & 0 deletions nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
worker_processes auto;
error_log /var/log/nginx/error.log notice;
pid /tmp/nginx.pid;

events {
worker_connections 1024;
}


http {
proxy_temp_path /tmp/proxy_temp;
client_body_temp_path /tmp/client_temp;
fastcgi_temp_path /tmp/fastcgi_temp;
uwsgi_temp_path /tmp/uwsgi_temp;
scgi_temp_path /tmp/scgi_temp;
include /etc/nginx/mime.types;
default_type application/octet-stream;

proxy_buffering off;

log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

access_log /var/log/nginx/access.log main;

sendfile on;
keepalive_timeout 65;
client_body_buffer_size 2M;
client_max_body_size 2M;

server {
listen 8080 default_server;
server_name localhost;
index index.php index.html index.htm;
root /var/www/html;
proxy_buffering off;

location / {
try_files $uri /index.php?$query_string;
}

location @rewrite {
rewrite ^/(.*)$ /index.php?q=$1;
}

# Serve the custom monitoring maps
location /sites/maps {
index index.html;
}

location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass flatbacks:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}

location ~ ^(/[a-z\-]+)?/sites/.*/files/(css|js|styles)/ { # For Drupal >= 7
try_files $uri @rewrite;
}

location ~ /\.ht {
deny all;
}

location = /favicon.ico {
log_not_found off;
access_log off;
}

location = /robots.txt {
log_not_found off;
access_log off;
allow all;
}

location ~* \.(css|gif|ico|jpeg|jpg|js|png)$ {
log_not_found off;
}

location = /serviceWorker.js {
access_log off;
return 200;
}
}
}

0 comments on commit 45b05a0

Please sign in to comment.