Skip to content
Snippets Groups Projects
Commit 5b9379a7 authored by Jedrzej Rybicki's avatar Jedrzej Rybicki
Browse files

docker file with volume

parent cc46135d
No related branches found
No related tags found
No related merge requests found
Pipeline #69746 passed
...@@ -91,7 +91,7 @@ The `context.py` file helps with importing the apiserver-packages, so that the t ...@@ -91,7 +91,7 @@ The `context.py` file helps with importing the apiserver-packages, so that the t
To build the docker image of the current version, simply run To build the docker image of the current version, simply run
```bash ```bash
docker build -t datacatalog-apiserver ./apiserver docker build -t datacatalog-apiserver -f ./apiserver/Dockerfile .
``` ```
while in the project root directory. while in the project root directory.
...@@ -101,13 +101,18 @@ while in the project root directory. ...@@ -101,13 +101,18 @@ while in the project root directory.
To run the docker image in a local container, run To run the docker image in a local container, run
```bash ```bash
docker run -d --name <container name> -p 127.0.0.1:<local_port>:8000 datacalog-apiserver docker run -d --name <container_name> -p <local_port>:8000 datacatalog-apiserver
``` ```
`<container name>` is the name of your container, that can be used to refer to it with other docker commands. `<container_name>` is the name of your container, that can be used to refer to it with other docker commands.
`<local_port>` is the port of your local machine, which will be forwarded to the docker container. For example, if it is set to `8080`, you will be able to reach the api-server at http://localhost:8080. `<local_port>` is the port of your local machine, which will be forwarded to the docker container. For example, if it is set to `8080`, you will be able to reach the api-server at http://localhost:8080.
For more production ready deployments consider using `--restart=always` flag, as well as inject path for data:
```bash
docker run -d --name <container_name> --restart=always -v /localvol/:/app/data/ -p <local_port>:8000 datacatalog-apiserver
```
#### Stopping the docker image #### Stopping the docker image
To stop the docker image, run To stop the docker image, run
......
FROM python:3.9-slim FROM python:3.9-slim
LABEL maintainer="Christian Böttcher <c.boettcher@fz-juelich.de>" LABEL maintainer="Christian Böttcher <c.boettcher@fz-juelich.de>"
EXPOSE 8000 EXPOSE 8000
VOLUME /app/data
RUN mkdir -p /app/data ADD ./apiserver/ /app/apiserver
RUN mkdir -p /app/apiserver ADD ./requirements.txt /app/apiserver/requirements.txt
RUN python3 -m pip install --no-cache-dir -r /app/apiserver/requirements.txt
RUN pip install "fastapi==0.63.0" \
"requests==2.25.1" \
"uvicorn==0.13.4" \
"python-dotenv==0.17.1" \
"python-multipart==0.0.5" \
"python-jose[cryptography]==3.2.0" \
"passlib[bcrypt]==1.7.4"
ADD . /app/apiserver
# set data directory properly for the docker container # set data directory properly for the docker container
RUN sed -i 's_./app/data_/app/data_g' /app/apiserver/config.env && sed -i 's_./app/userdb.json_/app/userdb.json_g' /app/apiserver/config.env RUN sed -i 's_./app/data_/app/data_g' /app/apiserver/config.env && sed -i 's_./app/userdb.json_/app/userdb.json_g' /app/apiserver/config.env
WORKDIR /app WORKDIR /app
ENTRYPOINT ["uvicorn", "--host", "0.0.0.0", "apiserver:app"] ENTRYPOINT ["uvicorn", "--host", "0.0.0.0", "apiserver:app"]
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment