Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setup_database.sh for docker db #180

Open
ghost opened this issue Jul 13, 2022 · 0 comments
Open

setup_database.sh for docker db #180

ghost opened this issue Jul 13, 2022 · 0 comments

Comments

@ghost
Copy link

ghost commented Jul 13, 2022

psql (specifically /usr/bin/psql from a docker host) doesn't smoothly interact with a postgres container with the project database.

I'm creating this Issue to share a simple workaround: prepend setup_database.sh with a local override for psql that proxies to docker exec. When present, everything works as expected.

psql() {
    docker exec -it $DB_CONTAINER psql -U $DB_USER $DB_NAME "$@"
}

The above works with sidecar containers that are started in a similar fashion to those defined in this example docker-compose.yml

---

myproject-db:
  image: postgres
  container_name: myproject-db
  environment:
    POSTGRES_DB: $DB_NAME
    POSTGRES_PASSWORD: $DB_PASSWORD
    POSTGRES_USER: $DB_USER
    PGDATA: /var/lib/postgresql/data/pgdata
  volumes:
    - /opt/volumes/myproject/db:/var/lib/postgresql/data/pgdata
  ports:
    - 5432:5432

myproject-redis:
  image: redis
  container_name: myproject-redis
  ports:
    - 6379:6379
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants