Giter VIP home page Giter VIP logo

openhsv-db's Introduction

OpenHSV (Postgres) Database

This repository contains a Docker image for the OpenHSV Postgres database. This image is an extension of Docker's official postgres image with start-up seed file for initializing the database (also called postgres) with dummy data.

How to Use

# build container image and assign name
docker build -t openhsv-db:1.0.0 .

# run container (uses seed.sql to populate db)
OPENHSV_CID=$(docker run --name openhsv-db -d -e POSTGRES_PASSWORD=password openhsv-db:1.0.0)

# connect to openhsv-db container in psql shell (may need to wait a few seconds)
docker run -it --rm --link openhsv-db:postgres postgres psql -h postgres -U postgres

# test query
postgres=# SELECT * from categories;

Optionally, you could connect via the Bash shell...

# connect to openhsv-db container in bash shell
docker exec -it ${OPENHSV_CID} /bin/bash

# open of psql shell within openhsv-db container
psql -U postgres

How to Debug

First, remove/comment the COPY command in the Dockerfile to inhibit the automatic import:

FROM postgres:latest

# (other commands)

# COPY ./seed.sql /docker-entrypoint-initdb.d/seed.sql

Then, take the following steps...

# build container image and assign name
docker build -t openhsv-db-debug:1.0.0 .

# mount local seed.sql file to the container's root directory
OPENHSV_DEBUG_CID=$(docker run --name openhsv-db-debug -d -v $(pwd)/seed.sql:/seed.sql -e POSTGRES_PASSWORD=password openhsv-db-debug:1.0.0)

# connect to openhsv-db-debug container in bash shell
docker exec -it ${OPENHSV_DEBUG_CID} /bin/bash

# attempt import of seed.sql file and look for errors
psql -U postgres -f seed.sql

Also, if you end up creating a bunch of containers you want to remove, then you can always run the following commands:

# stop and remove all containers
docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)

openhsv-db's People

Stargazers

Hector Patino avatar Tyler Hughes avatar

Watchers

James Cloos avatar Jarrod Parkes avatar Tyler Hughes avatar Jeremy Rogers avatar

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.