To use goose-docker as a goose command wrapper without any sugar around,
get an image with a -cmd suffix. It contains the goose executable as an entrypoint
without any predefined arguments.
There are two ways to add your migration files into the image:
- creating your own Dockerfile:
FROM ghcr.io/kukymbr/goose-docker-cmd:v3.27.1 ENV GOOSE_MIGRATION_DIR=/migrations ADD ./path/to/your/migrations /migrations
- using a volume:
docker run --rm ghcr.io/kukymbr/goose-docker-cmd:v3.27.1 \ -v ./path/to/your/migrations:/migrations \ <other arguments>
After adding a migrations, run an image with a required goose arguments.
Running the up command:
docker run --rm -v ./path/to/your/migrations:/migrations \
-e GOOSE_MIGRATION_DIR="/migrations" \
-e GOOSE_DRIVER="postgres" \
-e GOOSE_DBSTRING="host=localhost port=5432 user=postgres password=postgres dbname=postgres sslmode=disable" \
ghcr.io/kukymbr/goose-docker-cmd:v3.27.1 upRunning the up-to command:
docker run --rm -v ./path/to/your/migrations:/migrations \
ghcr.io/kukymbr/goose-docker-cmd:v3.27.1 \
-dir="/migrations" postgres "user=postgres dbname=postgres sslmode=disable" up-to 20230607203836Running the create command:
docker run --rm -v ./path/to/your/migrations:/migrations \
-e GOOSE_MIGRATION_DIR="/migrations" \
-e GOOSE_DRIVER="postgres" \
ghcr.io/kukymbr/goose-docker-cmd:v3.27.1 \
create my_new_feature sqlservices:
# ... Add your DB service
migrations:
image: ghcr.io/kukymbr/goose-docker-cmd:v3.27.1
environment:
- GOOSE_DRIVER=postgres
- GOOSE_DBSTRING=host=postgres port=5432 user=postgres password=postgres dbname=postgres
- GOOSE_MIGRATION_DIR=/migrations
volumes:
- ./migrations:/migrations
command: [ "up" ]