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

Adding docker setup feature #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM postgres:14.5
# requirements to run ./download
RUN apt-get update
RUN apt-get install -y wget && apt-get install -y bzip2

COPY . omdb-postgresql
COPY docker-import /docker-entrypoint-initdb.d/docker-import.sh

WORKDIR omdb-postgresql

RUN "./download"
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,14 @@ Create `omdb.dump` database export file:
```
pg_dump -Fc -f omdb.dump omdb
```

Using docker
--------------------------
Docker compose will create postgres database
and do the importing automatically.
Created database can be accessed using credentials
specified in environment section of the docker-compose.yaml.

```shell
docker compose up
```
12 changes: 12 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: "3"

services:
db:
build: .
container_name: "postgres_db"
environment:
POSTGRES_PASSWORD: omdbmovies
POSTGRES_USER: omdbmovies
POSTGRES_NAME: omdbmovies
ports:
- "54325:5432"
10 changes: 10 additions & 0 deletions docker-import
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh
set -eux

psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL
CREATE USER docker;
CREATE DATABASE demo;
GRANT ALL PRIVILEGES ON DATABASE demo TO docker;
CREATE EXTENSION IF NOT EXISTS tsm_system_rows;
\i omdb.sql
EOSQL