Skip to content

Commit d5195f8

Browse files
committed
Merge branch 'develop' into feature/parse-interface
2 parents 2174cd3 + eb8bafc commit d5195f8

7 files changed

Lines changed: 110 additions & 5 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,4 @@ venv.bak/
3636
# Node
3737
node_modules/
3838
frontend/src/environments/version.ts
39+
*~

CONTRIBUTING.md

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ This document contains basic documentation for developing LangPro Annotator.
44

55
## Before you start
66

7-
You need to install the following software:
7+
You need to install the following software, *unless* you will be using Docker:
88

99
- PostgreSQL >= 10, client, server and C libraries
1010
- Python >= 3.8, <= 3.10
@@ -36,7 +36,28 @@ Each subproject is configurable from the outside. Integration is achieved using
3636
If you are reading this document, you'll likely be working with the integrated project as a whole rather than with one of the subprojects in isolation. In this case, this document should be your primary source of information on how to develop or deploy the project. However, we recommend that you also read the "How it works" section in the document of each subproject.
3737

3838

39-
### Quickstart
39+
### Quickstart with Docker
40+
41+
```console
42+
docker compose up -d
43+
```
44+
45+
This will run the frontend and backend applications and watch all source files for changes. To run the backend unittests:
46+
47+
```console
48+
docker compose exec backend pytest
49+
```
50+
51+
To run the frontend unittests:
52+
53+
```console
54+
docker compose exec frontend yarn ng test --no-browsers
55+
```
56+
57+
then open http://localhost:9876 in a browser of choice.
58+
59+
60+
### Quickstart without Docker
4061

4162
First time after cloning this project:
4263

@@ -50,7 +71,12 @@ Running the application in [development mode][8] (hit ctrl-C to stop):
5071
$ yarn start
5172
```
5273

53-
This will run the backend and frontend applications, as well as their unittests, and watch all source files for changes. You can visit the frontend on http://localhost:8000/, the browsable backend API on http://localhost:8000/api/ and the backend admin on http://localhost:8000/admin/. On every change, unittests rerun, frontend code rebuilds and open browser tabs refresh automatically (livereload).
74+
This will run the backend and frontend applications, as well as their unittests, and watch all source files for changes.
75+
76+
77+
### Accessing the application
78+
79+
You can visit the frontend on http://localhost:8000/, the browsable backend API on http://localhost:8000/api/ and the backend admin on http://localhost:8000/admin/. On every change, unittests rerun, frontend code rebuilds and open browser tabs refresh automatically (livereload).
5480

5581
[8]: #development-mode-vs-production-mode
5682

backend/Dockerfile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
FROM python:3.11
2+
3+
WORKDIR /usr/src/app/backend
4+
COPY requirements.txt .
5+
RUN pip install -U pip pip-tools && pip-sync
6+
7+
COPY . .
8+
9+
CMD python manage.py check && \
10+
python manage.py migrate && \
11+
python manage.py runserver --settings glue --pythonpath .. 0.0.0.0:8000

docker-compose.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
services:
2+
postgres:
3+
image: postgres:15
4+
environment:
5+
- POSTGRES_PASSWORD=postgres
6+
healthcheck:
7+
test: 'psql -c "\l" postgres postgres'
8+
restart: always
9+
volumes:
10+
- postgres-data:/var/lib/postgresql/data
11+
- ./backend/create_db.sql:/docker-entrypoint-initdb.d/langpro.sql
12+
ports:
13+
- 127.0.0.1:5433:5432
14+
backend:
15+
build:
16+
context: ./backend
17+
environment:
18+
PGHOST: postgres
19+
LANGPRO_FRONTEND: 'http://frontend:4200'
20+
depends_on:
21+
postgres:
22+
condition: service_healthy
23+
healthcheck:
24+
test: 'curl -f localhost:8000/admin/'
25+
volumes:
26+
- ./:/usr/src/app
27+
ports:
28+
- 127.0.0.1:8000:8000
29+
frontend:
30+
build:
31+
context: ./frontend
32+
healthcheck:
33+
test: 'curl -f localhost:4200'
34+
volumes:
35+
- ./:/usr/src/app
36+
- frontend-node-modules:/usr/src/app/frontend/node_modules
37+
ports:
38+
- 127.0.0.1:4200:4200
39+
- 127.0.0.1:9876:9876
40+
41+
volumes:
42+
postgres-data:
43+
frontend-node-modules:

frontend/Dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
FROM node:20
2+
3+
WORKDIR /usr/src/app/frontend
4+
COPY . .
5+
6+
CMD yarn && yarn ng serve --host 0.0.0.0 --disable-host-check --proxy-config ../proxy.conf.docker.json

glue.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
backend/langpro_annotator/settings.py instead.
55
"""
66

7+
import os
78
import os.path as op
89

910
here = op.dirname(op.abspath(__file__))
@@ -39,5 +40,4 @@
3940
STATICFILES_DIRS += [
4041
op.join(here, 'frontend', 'src')
4142
]
42-
PROXY_FRONTEND = "http://localhost:4200"
43-
43+
PROXY_FRONTEND = os.getenv('LANGPRO_FRONTEND') or "http://localhost:4200"

proxy.conf.docker.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"/api": {
3+
"target": "http://backend:8000",
4+
"secure": false
5+
},
6+
"/users": {
7+
"target": "http://backend:8000",
8+
"secure": false
9+
},
10+
"/admin": {
11+
"target": "http://backend:8000",
12+
"secure": false
13+
},
14+
"/static": {
15+
"target": "http://backend:8000",
16+
"secure": false
17+
}
18+
}

0 commit comments

Comments
 (0)