-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: Add docker-compose file Adds a docker compose file which can be used for easily getting up and running with a dev environment. Adds material pulling into the Dockerfile with controllable behaviour via the MATERIAL_METHOD build-arg, either 'copy' in a local folder or pull the repo described in a local config yaml file. Also moves database migration to the entrypoint script so that a working database is not required at build-time. * fix: Remove wip comments from compose file * fix: Refer to correct .material file with volume mount config * fix: Ran prettier on README * feat: Adds cache-busting for git pull Adds support for cache-busting the git-pull of the material repo, meaning that the pull section of the dockerfile will not be run from the cached layer if the CACHE_BUST environment variable is changed between calls to `docker build` or `docker-compose build`. So far there seems no way to dynamically set the environment variable from within the compose file, so a script is included to do this manually via export, equally a prepended env variable could be used when calling `docker-compose build` or `... up --build`. * feat: Add nginx and qdrant to docker-compose * move docker compose instructions to docs * clean up nginx conf * added workflow to test docker compose build * sigh prettier * removed mount material to allow pulled material in container fixed some issues with the shell scripts --------- Co-authored-by: Alasdair Wilson <[email protected]>
- Loading branch information
1 parent
0f58e10
commit 32fc834
Showing
11 changed files
with
264 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
version: '3.9' | ||
|
||
x-vol-args: &args | ||
volumes: | ||
- ./.material:/app/.material | ||
|
||
services: | ||
db: | ||
image: postgres | ||
restart: always | ||
shm_size: 128mb | ||
environment: | ||
POSTGRES_PASSWORD: super-secret-password | ||
POSTGRES_USER: postgres | ||
ports: | ||
- "5432:5432" | ||
|
||
gutenberg: | ||
image: gutenberg | ||
build: | ||
context: . | ||
dockerfile: Dockerfile | ||
args: | ||
CACHE_BUST: ${CACHE_BUST} | ||
MATERIAL_METHOD: "pull" | ||
MATERIAL_DIR: ".material" | ||
YAML_TEMPLATE: "config/oxford.yaml" | ||
ports: | ||
- "3000:3000" | ||
links: | ||
- db | ||
<<: *args | ||
depends_on: | ||
db: | ||
condition: service_started | ||
environment: | ||
DATABASE_URL: postgresql://postgres:super-secret-password@db:5432 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# Use postgres/example user/password credentials | ||
version: "3.9" | ||
|
||
services: | ||
nginx: | ||
image: nginx:${NGINX_IMAGE_TAG} # stable-alpine3.19 | ||
volumes: | ||
- ./nginx:/etc/nginx/templates | ||
ports: | ||
- "80:8080" | ||
environment: | ||
- NGINX_HOST=localhost | ||
- NGINX_PORT=8080 | ||
- NGINX_PROXY_PASS=http://gutenberg:3000 | ||
depends_on: | ||
gutenberg: | ||
condition: service_started | ||
|
||
db: | ||
image: postgres | ||
restart: always | ||
shm_size: 128mb | ||
environment: | ||
POSTGRES_PASSWORD: super-secret-password | ||
POSTGRES_USER: postgres | ||
ports: | ||
- "5432:5432" | ||
volumes: | ||
- db-data:/var/lib/postgresql/data | ||
|
||
gutenberg: | ||
image: gutenberg | ||
build: | ||
context: . | ||
dockerfile: Dockerfile | ||
args: | ||
CACHE_BUST: ${CACHE_BUST} | ||
MATERIAL_METHOD: "pull" | ||
MATERIAL_DIR: ".material" | ||
YAML_TEMPLATE: "config/oxford.yaml" | ||
links: | ||
- db | ||
depends_on: | ||
db: | ||
condition: service_started | ||
environment: | ||
DATABASE_URL: postgresql://postgres:super-secret-password@db:5432 | ||
|
||
qdrant: | ||
image: qdrant | ||
build: | ||
context: qdrant/. | ||
dockerfile: Dockerfile | ||
ports: | ||
- "6333:6333" | ||
volumes: | ||
- qdrant_data:/qdrant/storage | ||
|
||
volumes: | ||
db-data: | ||
qdrant_data: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
--- | ||
Title: Deploying with Docker-compose | ||
permalink: /gutenberg/docker | ||
--- | ||
|
||
Gutenberg can be deployed both locally and to production using docker-compose. | ||
|
||
- `git` version 2.43.0 or later | ||
- `docker` version 18.03 or later | ||
|
||
Both of which will need to be installed following instructions for your system. | ||
|
||
Then we can get started by cloning the repository with git and entering into it with `cd`: | ||
|
||
```bash | ||
git clone https://github.com/OxfordRSE/gutenberg.git` | ||
cd gutenberg | ||
``` | ||
|
||
From here we can simply run: | ||
|
||
``` | ||
docker-compose up | ||
``` | ||
which should make gutenberg available to you at http://localhost:3000. This will | ||
build a Docker image the first time you run it (assuming you don't already have | ||
an image called `gutenburg` in your local registry) from the local source code - | ||
this might take a few minutes. If you want to force a rebuild after you've made | ||
some changes you can append the `--build` flag after `up`, i.e. | ||
``` | ||
docker-compose up --build | ||
``` | ||
Although this isn't particularly quick. By default the compose setup will pull | ||
the repo from the source defined in `config/oxford.yaml`, though you can change | ||
this from inside the `dev-compose.yml`, either by changing the `YAML_TEMPLATE` | ||
value (under `services.gutenberg.build.args`) to a different config yaml file or | ||
changing `MATERIAL_METHOD` to `"copy"` to copy a locally checked out folder into | ||
the container at build-time instead of pulling fresh - for more details on how | ||
to pull material to edit locally follow the below section. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
#!/bin/bash | ||
|
||
# Run migrations on the database | ||
npx prisma migrate deploy | ||
|
||
yarn cron & | ||
yarn start |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
server { | ||
listen ${NGINX_PORT}; | ||
server_name ${NGINX_HOST}; | ||
|
||
#access_log /var/log/nginx/host.access.log main; | ||
|
||
location / { | ||
proxy_pass ${NGINX_PROXY_PASS}; | ||
} | ||
|
||
#error_page 404 /404.html; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
export CACHE_BUST=$(date +%s) | ||
docker-compose build --build-arg CACHE_BUST=$CACHE_BUST |