You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
And a test script to run some integration tests after the migrations have been run on the db:
#!/usr/bin/env shset -e
docker compose up --wait
echo"docker compose up complete"# the "integration tests"
PGPASSWORD=123 psql -h localhost -p 5432 -U leo -d db -c "SELECT * FROM movies"||echo"failed"# clean up
docker compose down
Dockerfile-goose
FROM golang:alpine as builder
RUN apk add --no-cache git
RUN go install github.com/pressly/goose/v3/cmd/goose@latest
migrations/20240221040043_run.sql
-- +goose Up-- +goose StatementBeginSELECT pg_sleep(2); -- simulate migrations taking longer than they doCREATETABLEmovies (
id SERIALPRIMARY KEY,
title VARCHAR(255) NOT NULL
);
INSERT INTO movies (title) VALUES ('Woohoo');
-- +goose StatementEnd-- +goose Down-- +goose StatementBeginDROPTABLE IF EXISTS movies;
-- +goose StatementEnd
Notice how the docker compose file has to do some acrobatics with a "done" file flag. This is because docker compose up --wait does the following: Wait for services to be running|healthy. Implies detached mode.
The done file flag is used to make the migrations service only report healthy when the migrations are complete, so up --wait blocks until then and exits successfully so the test script continues.
Feature Request
It would be nice if you could indicate to up --wait that certain services will complete and up --wait should exit successfully if they do so, maybe with a new annotation in the compose file like:
That way the test script can remain agnostic to the names of particular services or containers and the compose file doesn't have to implement the "done" file creation and healthcheck.
The text was updated successfully, but these errors were encountered:
Description
Say you have a docker compose file that has 2 services:
And a test script to run some integration tests after the migrations have been run on the db:
Dockerfile-goose
migrations/20240221040043_run.sql
Notice how the docker compose file has to do some acrobatics with a "done" file flag. This is because
docker compose up --wait
does the following:Wait for services to be running|healthy. Implies detached mode.
The done file flag is used to make the migrations service only report healthy when the migrations are complete, so
up --wait
blocks until then and exits successfully so the test script continues.Feature Request
It would be nice if you could indicate to
up --wait
that certain services will complete andup --wait
should exit successfully if they do so, maybe with a new annotation in the compose file like:That way the test script can remain agnostic to the names of particular services or containers and the compose file doesn't have to implement the "done" file creation and healthcheck.
The text was updated successfully, but these errors were encountered: