Skip to content

Commit ca669a7

Browse files
committed
add docker setup for testing
1 parent 7177a3a commit ca669a7

File tree

6 files changed

+1014
-0
lines changed

6 files changed

+1014
-0
lines changed

.dockerignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.git
2+
__pycache__
3+
docker-compose.yaml
4+
Makefile
5+
.gitignore

Makefile

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# MAKEFILE SETTINGS
2+
# Silence default command echoing
3+
.SILENT:
4+
# Use one shell for all commands in a target recipe
5+
.ONESHELL:
6+
.EXPORT_ALL_VARIABLES:
7+
# Set phony targets
8+
.PHONY: help build up down
9+
# Set default goal
10+
.DEFAULT_GOAL := help
11+
# Use bash shell in Makefile instead of sh
12+
SHELL = /bin/bash
13+
14+
build: ## Build docker image
15+
docker compose build
16+
17+
up: build ## Run docker compose service
18+
docker compose up -d
19+
sleep 3
20+
echo "open http://127.0.0.1:8888/lab"
21+
bash -c "open http://127.0.0.1:8888/lab"
22+
sleep 2
23+
docker logs -n 1000 -f pgadmin-jupyterlab
24+
25+
down: ## Stop docker compose service
26+
docker compose down
27+
28+
rebuild: down up ## Rebuild docker compose service
29+
30+
# Display target comments in 'make help'
31+
help: ## Show this help
32+
grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'

docker-compose.yaml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
version: "3.9"
2+
3+
services:
4+
jupyterlab:
5+
image: jupyter/pgadmin:test
6+
build:
7+
context: "."
8+
dockerfile: setup/Dockerfile
9+
container_name: pgadmin-jupyterlab
10+
restart: always
11+
ports:
12+
- 8888:8888
13+
environment:
14+
PGHOST: postgres
15+
PGPORT: 5432
16+
PGDATABASE: postgres
17+
PGUSER: postgres
18+
PGPASSWORD: postgres
19+
volumes:
20+
- "${PWD}:/home/jovyan/jupyter-pgadmin-proxy"
21+
postgres:
22+
image: postgres:15.3-alpine
23+
hostname: postgres
24+
container_name: pgadmin-postgres
25+
restart: always
26+
environment:
27+
POSTGRES_DB: postgres
28+
POSTGRES_USER: postgres
29+
POSTGRES_PASSWORD: postgres
30+
volumes:
31+
- db:/var/lib/postgresql/data
32+
33+
volumes:
34+
db:
35+
name: db
36+

setup/Dockerfile

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
FROM jupyter/minimal-notebook:lab-3.6.1
2+
3+
USER root
4+
RUN set -x \
5+
&& apt-get update \
6+
&& apt-get install -y curl postgresql-client
7+
8+
WORKDIR /etc/pgadmin
9+
COPY setup/config_system.py /etc/pgadmin/config_system.py
10+
11+
# setup package, enable classic extension, build lab extension
12+
# USER "${NB_USER}"
13+
RUN mamba install -q -c conda-forge -y uwsgi simple-websocket psycopg
14+
RUN python3 -m pip install pgadmin4
15+
RUN fix-permissions /opt/conda
16+
17+
WORKDIR "${HOME}/jupyter-pgadmin-proxy"
18+
COPY . .
19+
RUN python3 -m pip install "${HOME}/jupyter-pgadmin-proxy"
20+
RUN fix-permissions /opt/conda
21+
22+
WORKDIR "${HOME}"
23+
# RUN python3 -m pip install git+https://github.com/huntdatacenter/jupyter-pgadmin-proxy.git
24+
RUN jupyter serverextension enable --sys-prefix jupyter_server_proxy
25+
RUN jupyter labextension disable "@jupyterlab/apputils-extension:announcements"
26+
27+
# copy configs, update permissions as root
28+
USER root
29+
RUN rm -rf "${HOME}/jupyter-pgadmin-proxy"
30+
RUN cp /etc/jupyter/jupyter_notebook_config.py /etc/jupyter/jupyter_notebook_config_base.py
31+
COPY setup/jupyter_notebook_config.py /etc/jupyter/jupyter_notebook_config.py
32+
RUN fix-permissions /etc/jupyter
33+
34+
35+
USER "${NB_USER}"

0 commit comments

Comments
 (0)