Skip to content

Commit 0a6f6e4

Browse files
committed
Rewrite Dockerfile with uv setup; Update README; Update pyproject.toml dependencies
1 parent d841679 commit 0a6f6e4

6 files changed

Lines changed: 87 additions & 93 deletions

File tree

Dockerfile

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,23 @@
1-
FROM python:3.10-alpine
1+
FROM python:3.10-slim
22

3-
ENV HOSTNAME=localhost
4-
ENV PORT=5000
5-
ENV MONGODB_HOST=localhost
6-
ENV MONGODB_PORT=27017
3+
RUN apt-get update && apt-get install -y --no-install-recommends curl ca-certificates
74

8-
RUN apk add --update --no-cache g++ gcc libxslt-dev
5+
# Steps to install uv (https://docs.astral.sh/uv/guides/integration/docker/#installing-uv)
6+
ENV UV_VERSION=0.8.13
7+
ADD https://astral.sh/uv/$UV_VERSION/install.sh /uv-installer.sh
98

10-
COPY requirements.txt /tmp/
9+
# Run the installer then remove it
10+
RUN sh /uv-installer.sh && rm /uv-installer.sh
1111

12-
RUN pip install --no-cache-dir -r /tmp/requirements.txt &&\
13-
addgroup -g 1000 esdlgroup &&\
14-
adduser -u 1000 -G esdlgroup -h /home/esdluser -D esdluser &&\
15-
mkdir /storage &&\
16-
chown esdluser: /storage
12+
# Ensure the installed binary is on the `PATH`
13+
ENV PATH="/root/.local/bin/:$PATH"
1714

18-
VOLUME /storage
15+
WORKDIR /code
1916

20-
WORKDIR /home/esdluser
21-
22-
USER esdluser
17+
# Install dependencies
18+
COPY ./pyproject.toml ./uv.lock ./
19+
RUN uv sync
2320

2421
COPY . .
2522

26-
CMD ["sh", "-c", "waitress-serve --listen *:$PORT --call esdlvalidator.api.manage:create_app"]
23+
CMD ["uv", "run", "waitress-serve", "--listen", "*:5000", "--call", "esdlvalidator.api.manage:create_app"]

README.md

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,13 @@ To run the service in debug mode.
191191
uv run app.py
192192
```
193193

194+
### Run ESDL-validator using waitress
195+
196+
An example how to start the service using waitress.
197+
198+
```
199+
uv run waitress-serve --listen="*:8080" --call "esdlvalidator.api.manage:create_app"
200+
```
194201

195202
### Testing
196203

@@ -227,7 +234,6 @@ Setting up Git hooks...
227234
✅ Git hook installed: .git/hooks/pre-push
228235
```
229236

230-
231237
#### Examples
232238

233239
When pushing to the internal gitlab repository with `git push`, you would see message like below and then proceed.
@@ -250,31 +256,13 @@ esdlvalidator/validation/functions/projects/nwn/test.py
250256

251257
## Docker
252258

253-
To test locally on docker desktop:
254-
255-
```
256-
docker-compose up --build
257-
```
258-
259-
Then go to [localhost:3011]() and `schema` POST to add a validation schema, `schema` GET will give a list of loaded
260-
schemas.
261-
To test the validator use `validationToMessages` POST with the esdl in regular text and the schema ID.
262-
263-
### OLD
264-
265-
Build example
266-
267-
```
268-
docker build -t esdl-validator .
269-
```
270-
271-
Run example for esdl-validator with logging set to DEBUG and the database file stored and read outside of the container.
259+
To test locally with docker desktop:
272260

273261
```
274-
docker run -p 8080:80 -v C:\temp:/storage -e ESDLVALIDATOR_LOG_LEVEL=DEBUG esdl-validator
262+
docker-compose -f docker-compose.yml up --build -d
275263
```
276264

277-
The service should now be accesible on ```localhost:8080```
265+
The service should now be accesible on ```localhost:3011```
278266

279267
## Validation
280268

docker-compose-poc.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
version: '3.8'
2-
31
networks:
42
mapeditor-net:
53
driver: bridge
@@ -15,6 +13,7 @@ services:
1513
- MONGODB_HOST=mongo
1614
- MONGODB_PORT=27017
1715
- PYTHONUNBUFFERED=1
16+
- ESDLVALIDATOR_LOG_LEVEL=DEBUG
1817
volumes:
1918
- validator-storage:/storage
2019
networks:

docker-compose.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
version: '3'
2-
31
networks:
42
esdl_val_net:
53

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ dependencies = [
1212
"flask-cors>=6.0.1",
1313
"flask-restx>=1.3.0",
1414
"pyesdl>=25.7",
15-
"pymongo>=4.14.1",
15+
"pymongo<=4.13",
1616
"tinydb>=4.8.2",
17+
"waitress>=3.0.2",
1718
]
1819

1920
[dependency-groups]

0 commit comments

Comments
 (0)