Golang code taken from Soham Kamani.
See Dockerfile for Birdpedia build instructions.
The docker-compose file will run:
- the birdpedia webapp container
- a Postgres database container
- a PGAdmin container, for creating managing your Postgres databases
docker-compose pull
docker-compose up
The next steps involve setting up the Postgres database via PGAdmin.
- Log into PGAdmin at localhost:5050 (see pgadmin environment creds in docker-compose)
- On command line, get the postgres docker container IP for the Server connection for pgAdmin:
docker inspect postgresql -f “{{json .NetworkSettings.Networks }}”
- Right click "Servers" and Create Server
- In General tab, call it anything sensible e.g., "my-postgres"
- In Connections tab, enter postgres container IP in "Host name/address", and in "Username" and "Password", use the postgres container creds (see postgres environment creds in docker-compose, i.e., "user" and "password")
- Click "Save" to create a new Server
- Right click "my-postgres" server and click Create > New Database
- Give database the correct name e.g., bird_encyclopedia
- Click Save
- In PGAdmin, go to Servers > Databases > > Schemas > Public > Tables
- Right click Tables, and Create Table
- Give Table the correct name of the Table used in your webapp DB calls i.e., "birds"
- Add the necessary columns according to the following SQL, and Save:
CREATE TABLE birds (
id SERIAL PRIMARY KEY,
bird VARCHAR(256),
description VARCHAR(1024)
);
- Right click Tables, and select "Query Tool"
- Run a test query:
INSERT INTO birds(species, description)
VALUES('House Sparrow', 'The house sparrow is a bird of the sparrow family Passeridae, found in most parts of the world');
SELECT species, description FROM birds;
With all this in place, you are ready to test out your webapp. Go to localhost:8080/assets/
If you want to run the containers separetely, without using docker-compose
docker run --name birdpedia -p 8080:8080 dvbridges/birdpedia:latest
Note, the username and password are required in the webapp for db entry
docker run --name postgresql -e POSTGRES_USER=user -e POSTGRES_PASSWORD=password -p 5432:5432 -v /data:/var/lib/postgresql/data -d postgres
Note, the username and password are for the Web UI login
docker run -p 5050:80 -e "PGADMIN_DEFAULT_EMAIL=pgadmin4@pgadmin.org" -e "PGADMIN_DEFAULT_PASSWORD=test1234" -d dpage/pgadmin4:4.29