diff --git a/README.md b/README.md index 9a0d5dd..f84d2db 100644 --- a/README.md +++ b/README.md @@ -18,13 +18,13 @@ pip install nebari-plugin-self-registration ## Running locally with Docker -_Note_: running locally requires a `config.yaml` file to be present within the `self-registration/dev` directory. Please rename the `sample.config.yaml` and update as needed before proceeding: +_Note_: running locally requires a `config.yaml` file to be present within the `self-registration` directory. Please create a copy of the `sample.config.yaml`, rename, and update as needed before proceeding: 1. Navigate to the `self-registration` directory 2. To build the docker image, run the following: ``` -docker build . -t self-registration +docker build . --file Dockerfile.local -t self-registration ``` 3. To run the app, run the following: diff --git a/self-registration/Dockerfile b/self-registration/Dockerfile index a892697..0269544 100644 --- a/self-registration/Dockerfile +++ b/self-registration/Dockerfile @@ -3,7 +3,6 @@ FROM python:3.12 WORKDIR /app COPY ./requirements.txt /tmp/requirements.txt -COPY ./dev . # need to pre-install cython < 3 to avoid pyyaml >= 5.4.1 incompatibility https://github.com/yaml/pyyaml/issues/601 RUN echo "cython<3" > /tmp/constraint.txt diff --git a/self-registration/Dockerfile.local b/self-registration/Dockerfile.local new file mode 100644 index 0000000..fa3d9c4 --- /dev/null +++ b/self-registration/Dockerfile.local @@ -0,0 +1,19 @@ +FROM python:3.12 + +WORKDIR /app + +COPY ./requirements.txt /tmp/requirements.txt +COPY ./config.yaml . + +# need to pre-install cython < 3 to avoid pyyaml >= 5.4.1 incompatibility https://github.com/yaml/pyyaml/issues/601 +RUN echo "cython<3" > /tmp/constraint.txt + +RUN PIP_CONSTRAINT=/tmp/constraint.txt pip install --no-cache-dir --upgrade -r /tmp/requirements.txt + +COPY ./app /app + +# Run web app as non-root +RUN useradd -m www +USER www + +CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"] \ No newline at end of file diff --git a/self-registration/dev/config.sample.yaml b/self-registration/config.sample.yaml similarity index 100% rename from self-registration/dev/config.sample.yaml rename to self-registration/config.sample.yaml diff --git a/self-registration/run.sh b/self-registration/run.sh index d2f1ef2..b532326 100755 --- a/self-registration/run.sh +++ b/self-registration/run.sh @@ -3,5 +3,5 @@ docker container stop self-registration docker container rm self-registration # Build and Run New Container -docker build . -t self-registration +docker build . --file Dockerfile.local -t self-registration docker run -d -p 8000:8000 --name self-registration self-registration \ No newline at end of file