build(containers): default to podman + update references
This commit is contained in:
parent
0bc89c927f
commit
b2c6a5a7ae
5 changed files with 27 additions and 22 deletions
|
@ -23,6 +23,9 @@ Note that this is the preferred way to running any tooling-related task within t
|
||||||
environment. Individual scripts exist under `/{frontend,backend}/script` but generally assume that they will be called
|
environment. Individual scripts exist under `/{frontend,backend}/script` but generally assume that they will be called
|
||||||
through `task` to inject some environment variables.
|
through `task` to inject some environment variables.
|
||||||
|
|
||||||
|
The project uses [Podman](https://podman.io/) as a default container manager, but is Docker-compatible
|
||||||
|
(`Taskfile.backend.yml` can be made to specify `CONTAINER_MANAGER="docker"` to use it).
|
||||||
|
|
||||||
#### Formatting
|
#### Formatting
|
||||||
|
|
||||||
Formatting in either frontend or backend environment can be done via `task {fe,be}:lint`. Applying fixes is available
|
Formatting in either frontend or backend environment can be done via `task {fe,be}:lint`. Applying fixes is available
|
||||||
|
@ -37,7 +40,7 @@ Test suites can be executed by environment via `task {fe,be}:test`.
|
||||||
The application requires a Postgres database instance to be made available to the backend. Setting up a local database
|
The application requires a Postgres database instance to be made available to the backend. Setting up a local database
|
||||||
is handled by the backend start command.
|
is handled by the backend start command.
|
||||||
|
|
||||||
Starting the backend (including a database) and frontend applications can be done via `task be:docker:start` and `task fe:start`.
|
Starting the backend (including a database) and frontend applications can be done via `task be:container:start` and `task fe:start`.
|
||||||
|
|
||||||
See the README files of each of those environments ([backend](./backend/README.md), [frontend](./frontend/README.md)) for specific requirements around `*.env` files that aren't committed with the code.
|
See the README files of each of those environments ([backend](./backend/README.md), [frontend](./frontend/README.md)) for specific requirements around `*.env` files that aren't committed with the code.
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ env:
|
||||||
APP_CONTAINER_NAME: "rotini_app"
|
APP_CONTAINER_NAME: "rotini_app"
|
||||||
DB_CONTAINER_NAME: "rotini_db"
|
DB_CONTAINER_NAME: "rotini_db"
|
||||||
SHELL: /bin/bash
|
SHELL: /bin/bash
|
||||||
|
CONTAINER_MANAGER: "podman"
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
bootstrap:
|
bootstrap:
|
||||||
|
@ -32,26 +33,28 @@ tasks:
|
||||||
test:
|
test:
|
||||||
desc: "Run the test suites."
|
desc: "Run the test suites."
|
||||||
deps: [bootstrap]
|
deps: [bootstrap]
|
||||||
cmd: $SHELL script/test {{ .CLI_ARGS }}
|
cmd: $SHELL script/test.sh {{ .CLI_ARGS }}
|
||||||
dotenv:
|
dotenv:
|
||||||
- ../backend-test.env
|
- ../backend-test.env
|
||||||
lock-deps:
|
lock-deps:
|
||||||
desc: "Locks production and development dependencies"
|
desc: "Locks production and development dependencies"
|
||||||
deps: [bootstrap]
|
deps: [bootstrap]
|
||||||
cmd: $SHELL script/requirements-lock
|
cmd: $SHELL script/requirements-lock
|
||||||
docker:start:
|
container:start:
|
||||||
desc: "Starts the backend application."
|
desc: "Starts the backend application."
|
||||||
deps: [docker:build]
|
deps: [container:build]
|
||||||
cmd: $SHELL script/start.sh
|
cmd: $SHELL script/start.sh
|
||||||
dotenv:
|
dotenv:
|
||||||
- ../backend.env
|
- ../backend.env
|
||||||
docker:stop:
|
container:stop:
|
||||||
desc: "Stops the backend application."
|
desc: "Stops the backend application."
|
||||||
cmd: docker rm -f {{ .APP_CONTAINER_NAME }} {{ .DB_CONTAINER_NAME }}
|
cmds:
|
||||||
docker:logs:
|
- "{{ .CONTAINER_MANAGER }} rm -f {{ .APP_CONTAINER_NAME }}"
|
||||||
desc: "Shortcut to Docker container logs"
|
- "{{ .CONTAINER_MANAGER }} rm -f {{ .DB_CONTAINER_NAME }}"
|
||||||
cmd: docker logs {{ .APP_CONTAINER_NAME }} -f
|
container:logs:
|
||||||
docker:build:
|
desc: "Shortcut to container container logs"
|
||||||
desc: "Builds a docker image from /backend"
|
cmd: "{{ .CONTAINER_MANAGER }} logs -f {{ .APP_CONTAINER_NAME }}"
|
||||||
|
container:build:
|
||||||
|
desc: "Builds a container image from /backend"
|
||||||
cmd: $SHELL script/build.sh
|
cmd: $SHELL script/build.sh
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
docker build -t rotini:dev .
|
$CONTAINER_MANAGER build -t rotini:dev .
|
||||||
|
|
|
@ -1,24 +1,24 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
docker network create rotini-local || echo "Network already exists"
|
$CONTAINER_MANAGER network create rotini-local || echo "Network already exists"
|
||||||
|
|
||||||
docker run \
|
$CONTAINER_MANAGER run \
|
||||||
--name $DB_CONTAINER_NAME \
|
--name $DB_CONTAINER_NAME \
|
||||||
-e POSTGRES_PASSWORD=$DB_PASSWORD \
|
-e POSTGRES_PASSWORD=$DB_PASSWORD \
|
||||||
-e POSTGRES_USER=$DB_USER \
|
-e POSTGRES_USER=$DB_USER \
|
||||||
-e POSTGRES_DB=$DB_NAME \
|
-e POSTGRES_DB=$DB_NAME \
|
||||||
-v $DATABASE_STORAGE_PATH:/var/lib/postgresql/data \
|
-v $DATABASE_STORAGE_PATH:/var/lib/postgresql/data:Z \
|
||||||
-p 5432:5432 \
|
-p 5432:5432 \
|
||||||
--network rotini-local \
|
--network rotini-local \
|
||||||
-d \
|
-d \
|
||||||
postgres:15.4
|
postgres:15
|
||||||
|
|
||||||
until [ -n "$(docker exec $DB_CONTAINER_NAME pg_isready | grep accepting)" ]; do
|
until [ -n "$($CONTAINER_MANAGER exec $DB_CONTAINER_NAME pg_isready | grep accepting)" ]; do
|
||||||
echo "Waiting for DB to come alive..."
|
echo "Waiting for DB to come alive..."
|
||||||
sleep 0.1;
|
sleep 0.1;
|
||||||
done;
|
done;
|
||||||
|
|
||||||
docker run \
|
$CONTAINER_MANAGER run \
|
||||||
--detach \
|
--detach \
|
||||||
--publish 8000:8000 \
|
--publish 8000:8000 \
|
||||||
--name $APP_CONTAINER_NAME \
|
--name $APP_CONTAINER_NAME \
|
||||||
|
|
|
@ -23,26 +23,25 @@ function fail {
|
||||||
|
|
||||||
# Cleanup before exit (success/failure)
|
# Cleanup before exit (success/failure)
|
||||||
function cleanup {
|
function cleanup {
|
||||||
docker rm $TEST_DB_CONTAINER -f > /dev/null || echo "Failed to clean up test database container."
|
$CONTAINER_MANAGER rm $TEST_DB_CONTAINER -f > /dev/null || echo "Failed to clean up test database container."
|
||||||
}
|
}
|
||||||
|
|
||||||
trap cleanup EXIT
|
trap cleanup EXIT
|
||||||
|
|
||||||
docker run \
|
$CONTAINER_MANAGER run \
|
||||||
--name $TEST_DB_CONTAINER \
|
--name $TEST_DB_CONTAINER \
|
||||||
-e POSTGRES_PASSWORD=test \
|
-e POSTGRES_PASSWORD=test \
|
||||||
-p 5431:5432 \
|
-p 5431:5432 \
|
||||||
-d \
|
-d \
|
||||||
postgres:15.4
|
postgres:15.4
|
||||||
|
|
||||||
until [ -n "$(docker exec $TEST_DB_CONTAINER pg_isready | grep accepting)" ]; do
|
until [ -n "$($CONTAINER_MANAGER exec $TEST_DB_CONTAINER pg_isready | grep accepting)" ]; do
|
||||||
echo "Waiting for DB to come alive..."
|
echo "Waiting for DB to come alive..."
|
||||||
sleep $HEALTHCHECK_SLEEP
|
sleep $HEALTHCHECK_SLEEP
|
||||||
done;
|
done;
|
||||||
|
|
||||||
sleep $HEALTHCHECK_SLEEP
|
sleep $HEALTHCHECK_SLEEP
|
||||||
|
|
||||||
#ROTINI_TEST=1 PYTHONPATH=rotini $VENV_PYTHON rotini/migrations/migrate.py up || fail "Migrations failed."
|
|
||||||
$VENV_PYTEST . -vv -s $@ || fail "Test run failed."
|
$VENV_PYTEST . -vv -s $@ || fail "Test run failed."
|
||||||
|
|
||||||
cleanup
|
cleanup
|
Reference in a new issue