-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🚧 progress: First attempt at defining CI MongoDB instances once.
- Loading branch information
1 parent
f41548a
commit 50199f3
Showing
11 changed files
with
167 additions
and
71 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
services: | ||
database: | ||
extends: | ||
file: ../storage.yaml | ||
service: database | ||
networks: | ||
- network | ||
|
||
networks: | ||
network: | ||
name: "${MONGO_NETWORK}" | ||
external: true |
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,19 @@ | ||
name: database-down | ||
description: > | ||
Stop the database container. | ||
inputs: | ||
|
||
runs: | ||
|
||
using: composite | ||
|
||
steps: | ||
|
||
- name: Stop database service | ||
run: | | ||
docker compose -f storage.yaml stop database | ||
- name: Remove database service | ||
run: | | ||
docker compose -f storage.yaml rm database |
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,52 @@ | ||
name: database-up | ||
description: > | ||
Run the database container. | ||
inputs: | ||
|
||
name: | ||
default: mongodb | ||
required: true | ||
|
||
hostname: | ||
required: true | ||
|
||
version: | ||
required: true | ||
|
||
replica-set: | ||
required: true | ||
|
||
network: | ||
required: true | ||
|
||
runs: | ||
|
||
using: composite | ||
|
||
steps: | ||
|
||
- name: Run a detached MongoDB container | ||
|
||
id: run | ||
|
||
env: | ||
MONGO_VERSION: ${{ inputs.version }} | ||
MONGO_REPLICA_SET_NAME: ${{ inputs.replica-set }} | ||
MONGO_DB_PATH: /data/db | ||
MONGO_HOSTNAME: ${{ inputs.hostname }} | ||
MONGO_NAME: ${{ inputs.name }} | ||
MONGO_NETWORK: ${{ inputs.network }} | ||
COMPOSE_FILE: ${{ inputs.network == 'host' && 'storage.yaml' || '.ci/storage.yaml' }} | ||
PUBLISH_FLAGS: ${{ inputs.network == 'host' && '--publish 27017:27017' || '' }} | ||
|
||
shell: bash | ||
|
||
run: | | ||
mkdir -p "${GITHUB_WORKSPACE}/${MONGO_DB_PATH}" | ||
docker compose -f "${COMPOSE_FILE}" run \ | ||
--detach \ | ||
${PUBLISH_FLAGS} \ | ||
--volume "${GITHUB_WORKSPACE}/${MONGO_DB_PATH}:${MONGO_DB_PATH}" \ | ||
--name "${MONGO_NAME}" \ | ||
database |
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
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,28 @@ | ||
services: | ||
database: | ||
restart: no | ||
image: "mongo:${MONGO_VERSION}" | ||
volumes: | ||
- ./scripts/assert-replica-set.js:/scripts/assert-replica-set.js | ||
logging: | ||
driver: "json-file" | ||
options: | ||
max-size: "100m" | ||
max-file: "7" | ||
command: [ | ||
"--bind_ip", "localhost,${MONGO_HOSTNAME}", | ||
"--dbpath", "${MONGO_DB_PATH}", | ||
"--replSet", "${MONGO_REPLICA_SET_NAME}" | ||
] | ||
healthcheck: | ||
test: [ | ||
"CMD", | ||
"mongo", | ||
"--eval", "replSet = '${MONGO_REPLICA_SET_NAME}'; hostname = '${MONGO_HOSTNAME}'", | ||
"/scripts/assert-replica-set.js" | ||
] | ||
start_period: 40s | ||
start_interval: 2s | ||
interval: 1m30s | ||
timeout: 10s | ||
retries: 3 |