Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nxy7/sqlx-cli-container
https://github.com/nxy7/sqlx-cli-container
Last synced: 10 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/nxy7/sqlx-cli-container
- Owner: nxy7
- Created: 2023-04-12T15:51:39.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-05-05T13:20:26.000Z (over 1 year ago)
- Last Synced: 2024-12-23T00:54:44.000Z (17 days ago)
- Language: Nix
- Size: 1000 Bytes
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Repository containing recipe for sqlx-cli docker image published to Docker Hub.
I'm using nix dockerTools to make resulting image as small as possible.I've made this image to have recent version of sqlx-cli to run migrations with docker compose instead of putting them in my app, which seems like much better workflow.
It's just sqlx-cli packaged into container, so you can refer to https://github.com/launchbadge/sqlx/tree/main/sqlx-cli for additional documentation.
# Usage
## With docker
```bash
docker run -v ./migrations:/migrations nxyt/sqlx-cli:latest migrate run --database-url=postgres://postgres:[email protected]:5432/postgres
```## With docker compose
```yaml
migrate:
image: nxyt/sqlx-cli
# optional if you want to wait till database containers is ready to accept connections
# depends_on:
# db:
# condition: service_healthy
command: migrate run
volumes:
- ./migrations:/migrations
environment:
- DATABASE_URL=postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@db:${POSTGRES_PORT}/${POSTGRES_DB}?sslmode=disable
```# Build image locally
## Prerequisites
```bash
nix
docker
```## Commands
```bash
nix build .
docker load -i result
# image is available as sqlx-cli:latest
```