Git Product home page Git Product logo

goose's Introduction

goose

This is a docker container for goose migrations. This is currently restricted to postgres databases only.

To use this repository, reference the linked docker image in your Dockerfile:

# mounts the local directory as the project db directory for goose
FROM shopkeep/goose

Also make sure you pass in the database credentials as environment variables, the container requires the following environment variables:

  • DB_HOST - The ip/hostname of the database
  • DB_PORT - The port of the database
  • DB_NAME - The name of the database
  • DB_USER - The username used to connect to the database
  • DB_PASSWORD - The users password
  • DB_SSL_MODE (optional) - The SSL mode, one of: disable, require (default), verify-full

To build the migrations container, run docker from your apps db directory:

# mounts the local directory into the container
$ docker build -t myapp_migration ./

# container exits when complete
$ docker run -i -e "DB_HOST=dbhost" -e "DB_PORT=dbport" -e "DB_NAME=dbname" -e "DB_USER=dbuser DB_SSL_MODE=disable" -e "DB_PASSWORD=dbpass" -t myapp_migration

The migrations directory is mounted at build-time, which includes entrypoint, and default CMD args. You can customize what migration is used by overriding the CMD args:

$ docker run -i -e "DB_HOST=dbhost" -e "DB_PORT=dbport" -e "DB_NAME=dbname" -e "DB_USER=dbuser" -e "DB_PASSWORD=dbpass" -e "DB_SSL_MODE=require" -t myapp_migration down
$ docker run -i -e "DB_HOST=dbhost" -e "DB_PORT=dbport" -e "DB_NAME=dbname" -e "DB_USER=dbuser" -e "DB_PASSWORD=dbpass" -e "DB_SSL_MODE=require" -t myapp_migration up

Instead of passing in environment arguments manually, you can define an environment file and pass it into docker using

$ docker run -i --env-file=./envfile -t myapp_migration

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.