Skip to content

Commit 7ed1265

Browse files
committed
Work
1 parent ef4a7e4 commit 7ed1265

File tree

5 files changed

+22
-31
lines changed

5 files changed

+22
-31
lines changed

.devcontainer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"dockerComposeFile": "docker-compose.dev.yml",
44
"service": "app",
55
"workspaceFolder": "/oc4ids_datastore_pipeline",
6+
"forwardPorts": [5432],
67
"customizations": {
78
"vscode": {
89
"extensions":["ms-python.python"]

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ RUN pip install -r requirements.txt
1111

1212
COPY . .
1313

14-
RUN pip install .
14+
RUN pip install -e .
1515

1616
ENTRYPOINT ["sh", "-c", "alembic upgrade head && oc4ids-datastore-pipeline"]

Dockerfile.dev

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ COPY . .
1313

1414
RUN pip install .
1515

16-
ENTRYPOINT ["sleep", "infinity"]
16+
CMD ["sleep", "infinity"]

README.md

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,16 @@
22

33
A Python application to validate and store published OC4IDS datasets.
44

5-
## Local Development
5+
## Local Development via Dev Containers or Docker Compose
66

7-
### Prerequisites
7+
You can open this repository in a dev container to get an environment complete with Postgres database.
88

9-
- Python 3.12
10-
- Postgres
11-
12-
### Install Python requirements
13-
14-
```
15-
python -m venv .venv
16-
source .venv/bin/activate
17-
pip install -r requirements_dev.txt
18-
```
19-
20-
### Set database enrivonment variable
9+
If you prefer to use Docker Compose, you can instead run:
2110

2211
```
23-
export DATABASE_URL="postgresql://oc4ids_datastore@localhost/oc4ids_datastore"
12+
docker compose -f docker-compose.dev.yml up -d
13+
docker compose -f docker-compose.dev.yml exec app bash
14+
docker compose -f docker-compose.dev.yml stop
2415
```
2516

2617
### Run database migrations
@@ -92,6 +83,17 @@ To send failure notifications by email, the following environment variables must
9283
pip install -e .
9384
oc4ids-datastore-pipeline
9485
```
86+
### Access Database
87+
88+
From inside the dev container or Docker container:
89+
90+
```
91+
psql postgresql://postgres:postgres@localhost:5432/postgres
92+
```
93+
94+
Connecting from outside:
95+
* If using a dev container or Docker Compose locally the same command should work
96+
* In GitHub Codespaces, we're not sure how to access the port
9597

9698
### Run linting and type checking
9799

docker-compose.dev.yml

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,13 @@ services:
33
build:
44
context: .
55
dockerfile: Dockerfile.dev
6-
76
volumes:
87
- .:/oc4ids_datastore_pipeline:cached
9-
10-
# Overrides default command so things don't shut down after the process ends.
11-
#command: sleep infinity
12-
138
# Runs app on the same network as the database container, allows "forwardPorts" in devcontainer.json function.
149
network_mode: service:db
15-
16-
# Use "forwardPorts" in **devcontainer.json** to forward an app port locally.
17-
# (Adding the "ports" property to this file will not forward from a Codespace.)
1810
environment:
1911
- DATABASE_URL=postgresql://postgres:postgres@localhost/postgres
2012

21-
entrypoint: sleep infinity
22-
2313
db:
2414
image: postgres:latest
2515
restart: unless-stopped
@@ -29,11 +19,9 @@ services:
2919
POSTGRES_USER: postgres
3020
POSTGRES_DB: postgres
3121
POSTGRES_PASSWORD: postgres
22+
# Forwarding this port so people can access the DB when run via Docker Compose.
3223
ports:
33-
- 54321:5432
34-
35-
# Add "forwardPorts": ["5432"] to **devcontainer.json** to forward PostgreSQL locally.
36-
# (Adding the "ports" property to this file will not forward from a Codespace.)
24+
- 5432:5432
3725

3826
volumes:
3927
postgres-data:

0 commit comments

Comments
 (0)