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
|
||||
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 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
|
||||
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.
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ env:
|
|||
APP_CONTAINER_NAME: "rotini_app"
|
||||
DB_CONTAINER_NAME: "rotini_db"
|
||||
SHELL: /bin/bash
|
||||
CONTAINER_MANAGER: "podman"
|
||||
|
||||
tasks:
|
||||
bootstrap:
|
||||
|
@ -32,26 +33,28 @@ tasks:
|
|||
test:
|
||||
desc: "Run the test suites."
|
||||
deps: [bootstrap]
|
||||
cmd: $SHELL script/test {{ .CLI_ARGS }}
|
||||
cmd: $SHELL script/test.sh {{ .CLI_ARGS }}
|
||||
dotenv:
|
||||
- ../backend-test.env
|
||||
lock-deps:
|
||||
desc: "Locks production and development dependencies"
|
||||
deps: [bootstrap]
|
||||
cmd: $SHELL script/requirements-lock
|
||||
docker:start:
|
||||
container:start:
|
||||
desc: "Starts the backend application."
|
||||
deps: [docker:build]
|
||||
deps: [container:build]
|
||||
cmd: $SHELL script/start.sh
|
||||
dotenv:
|
||||
- ../backend.env
|
||||
docker:stop:
|
||||
container:stop:
|
||||
desc: "Stops the backend application."
|
||||
cmd: docker rm -f {{ .APP_CONTAINER_NAME }} {{ .DB_CONTAINER_NAME }}
|
||||
docker:logs:
|
||||
desc: "Shortcut to Docker container logs"
|
||||
cmd: docker logs {{ .APP_CONTAINER_NAME }} -f
|
||||
docker:build:
|
||||
desc: "Builds a docker image from /backend"
|
||||
cmds:
|
||||
- "{{ .CONTAINER_MANAGER }} rm -f {{ .APP_CONTAINER_NAME }}"
|
||||
- "{{ .CONTAINER_MANAGER }} rm -f {{ .DB_CONTAINER_NAME }}"
|
||||
container:logs:
|
||||
desc: "Shortcut to container container logs"
|
||||
cmd: "{{ .CONTAINER_MANAGER }} logs -f {{ .APP_CONTAINER_NAME }}"
|
||||
container:build:
|
||||
desc: "Builds a container image from /backend"
|
||||
cmd: $SHELL script/build.sh
|
||||
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
#!/bin/bash
|
||||
|
||||
docker build -t rotini:dev .
|
||||
$CONTAINER_MANAGER build -t rotini:dev .
|
||||
|
|
|
@ -1,24 +1,24 @@
|
|||
#!/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 \
|
||||
-e POSTGRES_PASSWORD=$DB_PASSWORD \
|
||||
-e POSTGRES_USER=$DB_USER \
|
||||
-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 \
|
||||
--network rotini-local \
|
||||
-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..."
|
||||
sleep 0.1;
|
||||
done;
|
||||
|
||||
docker run \
|
||||
$CONTAINER_MANAGER run \
|
||||
--detach \
|
||||
--publish 8000:8000 \
|
||||
--name $APP_CONTAINER_NAME \
|
||||
|
|
|
@ -23,26 +23,25 @@ function fail {
|
|||
|
||||
# Cleanup before exit (success/failure)
|
||||
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
|
||||
|
||||
docker run \
|
||||
$CONTAINER_MANAGER run \
|
||||
--name $TEST_DB_CONTAINER \
|
||||
-e POSTGRES_PASSWORD=test \
|
||||
-p 5431:5432 \
|
||||
-d \
|
||||
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..."
|
||||
sleep $HEALTHCHECK_SLEEP
|
||||
done;
|
||||
|
||||
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."
|
||||
|
||||
cleanup
|
Reference in a new issue