Skip to content

Commit

Permalink
Merge pull request #15 from knopki/tweak-dockerf-compose
Browse files Browse the repository at this point in the history
docker compose tweaks
  • Loading branch information
blokhin authored May 23, 2023
2 parents 5cb674f + 236ec95 commit cf1de4c
Show file tree
Hide file tree
Showing 8 changed files with 157 additions and 109 deletions.
117 changes: 117 additions & 0 deletions .docker/common.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
---
version: "3.9"
services:
db:
container_name: metis-db
image: docker.io/library/postgres:14
environment:
POSTGRES_USER: &dbuser metis
POSTGRES_PASSWORD: &dbpassword password
POSTGRES_DB: &dbname metis
POSTGRESQL_POSTGRES_PASSWORD: *dbpassword
volumes:
- db-data:/var/lib/postgresql/data
healthcheck:
test: pg_isready -U metis
interval: 5s
timeout: 5s
retries: 10

rabbitmq:
container_name: metis-rmq
image: docker.io/library/rabbitmq:3.8.14-management
environment:
RABBITMQ_DEFAULT_USER: &rabbituser guest
RABBITMQ_DEFAULT_PASS: &rabbitpass guest
volumes:
- rmq-data:/var/lib/rabbitmq/
healthcheck:
test: rabbitmq-diagnostics -q ping
interval: 30s
timeout: 30s
retries: 5

metis-backend:
container_name: metis-backend
environment:
PGDATABASE: *dbname
PGHOST: db
PGPASSWORD: *dbpassword
PGUSER: *dbuser
RMQHOST: rabbitmq
RMQPASSWORD: *rabbitpass
RMQUSER: *rabbituser
TZ: Europe/Berlin
USER_EMAIL: aiida@localhost
USER_FIRST_NAME: Giuseppe
USER_LAST_NAME: Verdi
USER_INSTITUTION: LaScala
HOST: "0.0.0.0"
API_KEY: &apikey a-very-very-very-long-and-very-very-very-secret-string
WEBHOOKS_KEY: &webhookskey another-very-very-long-and-very-very-very-secret-string
WEBHOOKS_CALC_UPDATE: http://metis-bff:3000/v0/webhooks/calc_update
WEBHOOKS_CALC_CREATE: http://metis-bff:3000/v0/webhooks/calc_create
YASCHEDULER_DUMMY_ENGINE_URL: https://github.com/tilde-lab/dummy-engine/releases/download/v0.0.3/dummyengine
YASCHEDULER_LOCAL_DATA_DIR: "/data"
YASCHEDULER_ADD_NODE_HOST: yanode
YASCHEDULER_ADD_NODE_USER: user
volumes:
- metis-backend-home:/root
- metis-data:/data
ports:
- "7050:7050"
healthcheck:
test: curl http://localhost:7050/calculations/template
interval: 5s
timeout: 5s
retries: 10

metis-bff:
container_name: metis-bff
depends_on:
db:
condition: service_healthy
metis-backend:
condition: service_healthy
environment:
PG_NAME: *dbname
PG_HOST: db
PG_USER: *dbuser
PG_PASSWORD: *dbpassword
API_SCHEMA: http
API_HOST: metis-backend
API_PORT: "7050"
API_KEY: *apikey
# TODO: WEBHOOKS_KEY
ports:
- "3000:3000"

metis-gui:
container_name: metis-gui
environment:
PORT: "8080"
FORCE_HTTPS: "0"
PROXY_BFF_API_URL: "http://metis-bff:3000"
METIS_RUNTIME_CONFIG: |
{
'API_HOST': location.origin.concat('/api'),
'IDPS': ['local'],
}
ports:
- "10000:8080"

yanode:
image: docker.io/linuxserver/openssh-server:latest
container_name: yanode
environment:
- PUID=1000
- PGID=1000
- PUBLIC_KEY_DIR=/pubkeys
- SUDO_ACCESS=true
- PASSWORD_ACCESS=false
- USER_NAME=user
- PORT=22
sysctls:
- "net.ipv4.ip_unprivileged_port_start=0"
ports:
- "10022:2222"
Empty file.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
.docker/common.yml
.docker/db
Dockerfile
compose.yml
compose.*.yml
backups
15 changes: 4 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,22 +57,15 @@ One by one, all the parts are managed as follows:
This is an experimental feature intended primarily for development and testing.

It is assumed that you have the `metis-backend`, `metis-bff`, and `metis-gui`
repositories cloned on the same level. Also, you need `docker` and `docker-compose`
(or `podman` and `podman-compose`) installed.
repositories cloned on the same level. Also, you need `docker` (or `podman`
and `podman-compose`) installed.

Now, you can run `docker-compose up` (`podman-compose up`) in `metis-backend`
Now, you can run `docker compose up` (`podman-compose up`) in `metis-backend`
directory. This should start all dependencies and services.

`metis-gui` should be available at `http://localhost:10000/`

`metis-bff` shoult be available at `http://localhost:3000/`

For development you can start services with overrides. For example, if you want, start `metis-backend` in dev mode, run
`docker-compose -f compose.yml -f compose.dev-backend.yml up`.
If you want, start `metis-bff` in dev mode, run
`docker-compose -f compose.yml -f compose.dev-bff.yml up`.
You can combine modes:
`docker-compose -f compose.yml -f compose.dev-backend.yml -f compose.dev-bff.yml up`.
`metis-bff` should be available at `http://localhost:3000/`

## License

Expand Down
5 changes: 0 additions & 5 deletions compose.dev-backend.yml

This file was deleted.

8 changes: 0 additions & 8 deletions compose.dev-bff.yml

This file was deleted.

4 changes: 4 additions & 0 deletions compose.prod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
version: "3.9"
services: {}
# there is no production version ha ha
115 changes: 30 additions & 85 deletions compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,11 @@
version: "3.9"
services:
db:
container_name: metis-db
image: docker.io/library/postgres:14
environment:
POSTGRES_USER: &dbuser metis
POSTGRES_PASSWORD: &dbpassword password
POSTGRES_DB: &dbname metis
POSTGRESQL_POSTGRES_PASSWORD: *dbpassword
extends:
file: .docker/common.yml
service: db
volumes:
- ./.docker/db/pgcrypto.sql:/docker-entrypoint-initdb.d/10-pgcrypto.sql
- db-data:/var/lib/postgresql/data
healthcheck:
test: pg_isready -U metis
interval: 5s
timeout: 5s
retries: 10

adminer:
container_name: metis-adminer
Expand All @@ -26,95 +16,53 @@ services:
- "10003:8080"

metis-backend:
container_name: metis-backend
extends:
file: .docker/common.yml
service: metis-backend
build:
context: .
depends_on:
db:
condition: service_healthy
# rabbitmq:
# condition: service_healthy
build:
context: .
environment:
PGDATABASE: *dbname
PGHOST: db
PGPASSWORD: *dbpassword
PGUSER: *dbuser
TZ: Europe/Berlin
HOST: "0.0.0.0"
API_KEY: &apikey a-very-very-very-long-and-very-very-very-secret-string
WEBHOOKS_KEY: &webhookskey another-very-very-long-and-very-very-very-secret-string
WEBHOOKS_CALC_UPDATE: http://metis-bff:3000/v0/webhooks/calc_update
WEBHOOKS_CALC_CREATE: http://metis-bff:3000/v0/webhooks/calc_create
YASCHEDULER_DUMMY_ENGINE_URL: https://github.com/tilde-lab/dummy-engine/releases/download/v0.0.3/dummyengine
YASCHEDULER_LOCAL_DATA_DIR: "/data"
YASCHEDULER_ADD_NODE_HOST: yanode
YASCHEDULER_ADD_NODE_USER: user
volumes:
- metis-backend-home:/root
- metis-data:/data
- .docker/s6-rc.d:/etc/s6-overlay/s6-rc.d
- .:/app
- yanode-pubkeys:/yanode-put-pubkey-here
# auto add yanode:
- .docker/empty:/etc/s6-overlay/s6-rc.d/user/contents.d/yascheduler-add-node
ports:
- "7050:7050"
healthcheck:
test: curl http://localhost:7050/calculations/template
interval: 5s
timeout: 5s
retries: 10

metis-bff:
container_name: metis-bff
extends:
file: .docker/common.yml
service: metis-bff
build:
args:
- NODE_ENV=development
context: ../metis-bff
depends_on:
db:
condition: service_healthy
metis-backend:
condition: service_healthy
build:
context: ../metis-bff
environment:
PG_NAME: *dbname
PG_HOST: db
PG_USER: *dbuser
PG_PASSWORD: *dbpassword
API_SCHEMA: http
API_HOST: metis-backend
API_PORT: "7050"
API_KEY: *apikey
# TODO: WEBHOOKS_KEY
ports:
- "3000:3000"
volumes:
- ../metis-bff:/app
entrypoint: "npm run dev"

metis-gui:
container_name: metis-gui
extends:
file: .docker/common.yml
service: metis-gui
depends_on: ["metis-bff"]
build:
context: ../metis-gui
environment:
PORT: "8080"
FORCE_HTTPS: "0"
PROXY_BFF_API_URL: "http://metis-bff:3000"
METIS_RUNTIME_CONFIG: |
{
'API_HOST': location.origin.concat('/api'),
'IDPS': ['local'],
}
ports:
- "10000:8080"
METIS_RUNTIME_CONFIG_SRC: "/srv/index_html.orig"
volumes:
- ../metis-gui/dist/index.html:/srv/index_html.orig
- ../metis-gui/dist/build:/srv/build

yanode:
image: docker.io/linuxserver/openssh-server:latest
container_name: yanode
environment:
- PUID=1000
- PGID=1000
- PUBLIC_KEY_DIR=/pubkeys
- SUDO_ACCESS=true
- PASSWORD_ACCESS=false
- USER_NAME=user
- PORT=22
sysctls:
- "net.ipv4.ip_unprivileged_port_start=0"
extends:
file: .docker/common.yml
service: yanode
volumes:
- .docker/empty:/etc/s6-overlay/s6-rc.d/init-config/dependencies.d/wait-pubkey:ro
- .docker/yanode/s6-rc.d/wait-pubkey:/etc/s6-overlay/s6-rc.d/wait-pubkey:ro
Expand All @@ -123,9 +71,6 @@ services:
- yanode-host-keys:/config/ssh_host_keys
- yanode-pubkeys:/pubkeys
- yanode-data:/config/data
ports:
- "10022:2222"


volumes:
db-data: {}
Expand Down

0 comments on commit cf1de4c

Please sign in to comment.