From c2052bb7c6c51d4cfd7ed30a4623bb78cac1a87d Mon Sep 17 00:00:00 2001 From: Brian Cherinka Date: Thu, 22 Feb 2024 14:43:01 -0500 Subject: [PATCH] adding readme and service name and image tag option --- docker/Dockerfile | 7 +++--- docker/README.md | 46 +++++++++++++++++++++++++++++++++++++++ docker/docker-compose.yml | 7 +++++- 3 files changed, 56 insertions(+), 4 deletions(-) create mode 100644 docker/README.md diff --git a/docker/Dockerfile b/docker/Dockerfile index 1748c383..dbc0b86f 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -10,11 +10,12 @@ RUN apt-get update && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* +# Define an argument for the Git tag, defaulting to "main" +ARG MARVIN_TAG=main + # Clone the repository and checkout the specific tag RUN git clone https://github.com/sdss/marvin.git /app && \ - git checkout docker -#COPY . /app - + git checkout ${MARVIN_TAG} # Install any needed packages RUN pip install --no-cache-dir ".[web,db]" diff --git a/docker/README.md b/docker/README.md new file mode 100644 index 00000000..04938c7d --- /dev/null +++ b/docker/README.md @@ -0,0 +1,46 @@ + + +# Marvin Docker + +Describes the setup of a containerized system hosting the Marvin +web application. + + +## Initial Setup + +There are two bind mounts: + +- The SDSS SAS filesystem +- The host machine pgpass config file + +1. Set a `SAS_BASE_DIR` environment variable that points to the +top level directory of the SDSS SAS filesystem. + +2. Create or check that a pgpass config file exists at `$HOME/.pgpass`, which contains the manga database connection string info `host.docker.internal:5432:manga:marvin:(password)`. Replace the `(password)` with the local database password. + +The marvin docker setup attempts to connect to the local host machine postgres database directly using `host.docker.internal` + + +## Run docker compose + +All commands are relative to within the docker folder. From the top-level repo, run `cd docker` + +To build and run the docker compose system: +```bash +docker compose up +``` +To force a build, you can do: `docker compose up --build` + +Navigate to `http://localhost:8080/marvin/`. + +To bring the system down: +```bash +docker compose down +``` + +The docker compose system starts three services: +- Marvin Webapp - the backend web application, mounted to port 8000 +- Nginx - the nginx web service, mounted to port 8080 +- Redis - a redis database for caching + +The final web application is available at `localhost:8080/marvin` \ No newline at end of file diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 0926386c..9ed5e56d 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -1,4 +1,5 @@ version: '3.9' +name: marvin services: nginx: container_name: nginx @@ -33,7 +34,11 @@ services: marvin: container_name: marvin - image: marvin:latest + build: + context: . + args: + MARVIN_TAG: ${MARVIN_TAG:-main} + image: marvin:${MARVIN_TAG:-latest} ports: - 8000:8000 volumes: