diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 34d53350..55c861f2 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,17 +1,18 @@ [bumpversion] -current_version = 2.8.2 +current_version = 2.8.3dev commit = True tag = False tag_name = {new_version} parse = (?P\d+)\.(?P\d+)\.(?P\d+)(?P[a-z]+)? -serialize = +serialize = {major}.{minor}.{patch}{release} {major}.{minor}.{patch} [bumpversion:part:release] optional_value = alpha -values = +values = dev alpha [bumpversion:file:setup.cfg] + diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 00000000..157aca16 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,56 @@ +name: Docker + +on: + push: + tags: + - '[0-9]+.[0-9]+.[0-9]+' # Exclude pre-releases + branches: + - main + +jobs: + docker: + runs-on: ubuntu-latest + env: + USER: sdss + APP: marvin + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Set docker tags + id: set-tags + run: | + echo TAG_LATEST=$USER/$APP:latest >> $GITHUB_OUTPUT + if [[ $GITHUB_REF == refs/heads/main ]] + then + echo TAGS=$USER/$APP:latest >> $GITHUB_OUTPUT + elif [[ $GITHUB_REF == refs/heads/* ]] + then + BRANCH=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's/[\/]/_/g') + echo TAGS=$USER/$APP:$BRANCH >> $GITHUB_OUTPUT + else + echo TAGS=$USER/$APP:${GITHUB_REF#refs/tags/} >> $GITHUB_OUTPUT + fi + - name: Show tags + run: echo ${{ steps.set-tags.outputs.TAGS }} + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Log in to registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Build and push + id: docker_build + uses: docker/build-push-action@v4 + with: + push: true + tags: | + ghcr.io/${{ steps.set-tags.outputs.TAGS }} + ghcr.io/${{ steps.set-tags.outputs.TAG_LATEST }} + context: docker + file: docker/Dockerfile + - name: Image digest + run: echo ${{ steps.docker_build.outputs.digest }} \ No newline at end of file diff --git a/CHANGELOG.rst b/CHANGELOG.rst index c87c2789..38cd3503 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,6 +1,13 @@ Marvin's Change Log =================== + +[2.8.3] - 2025/06/12 +-------------------- +- Removed header UI user login to fix bug in web deploy +- Updated docker build to fix deps issues +- Adding docker github action + [2.8.2] - 2025/02/05 -------------------- - Updating build to comply with PEP 625 diff --git a/docker/Dockerfile b/docker/Dockerfile index dbc0b86f..e37f1652 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -22,10 +22,9 @@ RUN pip install --no-cache-dir ".[web,db]" # Resolve some dependency issues RUN pip install gunicorn -RUN pip install "jinja2<3.1" -RUN pip install "packaging<21" RUN pip install "itsdangerous==2.0.1" RUN pip install "pillow<10" +RUN pip install "marshmallow<4.0.0" # Create the log directory and ensure it's writable RUN mkdir -p /tmp/marvin/logs && \ @@ -47,6 +46,10 @@ RUN chmod -R 755 /app/python/marvin/web # Set environment variables ENV FLASK_APP="marvin.web.uwsgi_conf_files.app:app" +# Set a label +LABEL org.opencontainers.image.source=https://github.com/sdss/marvin +LABEL org.opencontainers.image.description="marvin production image" + # Change to python dir WORKDIR /app/python diff --git a/docker/Dockerfile.dev b/docker/Dockerfile.dev new file mode 100644 index 00000000..05e82020 --- /dev/null +++ b/docker/Dockerfile.dev @@ -0,0 +1,49 @@ +# Use an official Python runtime as a parent image +FROM python:3.10-slim + +# Set the working directory in the container +WORKDIR /app + +# Install library files +RUN apt-get update && \ + apt-get install -y --no-install-recommends git libpq-dev gcc build-essential mime-support && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +# Copy the repo contents into the container +COPY ./ /app + +# Install any needed packages +RUN pip install --no-cache-dir ".[web,db]" + +# Resolve some dependency issues +RUN pip install gunicorn +RUN pip install "itsdangerous==2.0.1" +RUN pip install "pillow<10" +RUN pip install "marshmallow<4.0.0" + +# Create the log directory and ensure it's writable +RUN mkdir -p /tmp/marvin/logs && \ + chmod -R 755 /tmp/marvin + +# Make port 8000 available to the world outside this container +EXPOSE 8000 + +# Copy the gunicorn config file into the container +COPY docker/gunicorn_config.py /app/python/gunicorn_config.py + +# Create the marvin config file +RUN mkdir -p /root/.marvin && chmod -R 755 /root/.marvin +RUN echo "use_sentry: False\nadd_github_message: False\ncheck_access: False" > /root/.marvin/marvin.yml + +# Update permissions +RUN chmod -R 755 /app/python/marvin/web + +# Set environment variables +ENV FLASK_APP="marvin.web.uwsgi_conf_files.app:app" + +# Change to python dir +WORKDIR /app/python + +# Run the application with uWSGI +CMD ["gunicorn", "-c", "gunicorn_config.py", "marvin.web.uwsgi_conf_files.app:app"] diff --git a/docker/README.md b/docker/README.md index ea7dcf8f..e0bc741c 100644 --- a/docker/README.md +++ b/docker/README.md @@ -50,4 +50,13 @@ The final web application is available at `localhost:8080/marvin` By default the marvin docker build will checkout the latest `main` branch of marvin on github and tag the image as `marvin:latest`. To change this to a specific branch or tag of marvin, e.g. `2.8.0` or `branch_name`, set the `MARVIN_TAG` environment variable. Then rebuild the system with `docker compose up --build`. This will checkout that branch or tag of the marvin repository and create -a new marvin docker image with that tag name. \ No newline at end of file +a new marvin docker image with that tag name. + +## Developer Notes + +To run the local developer docker, run the following command from the top level marvin project directory: +```bash +docker compose -f docker/docker-compose-dev.yml up --build +``` + +If you do not have a local postgres manga database, you can create a tunnel to the manga db at JHU. \ No newline at end of file diff --git a/docker/docker-compose-dev.yml b/docker/docker-compose-dev.yml new file mode 100644 index 00000000..74db069b --- /dev/null +++ b/docker/docker-compose-dev.yml @@ -0,0 +1,56 @@ +version: '3.9' +name: marvin +services: + nginx: + container_name: nginx + image: nginx:latest + volumes: + - ./nginx.conf:/etc/nginx/nginx.conf + - socket_logs:/tmp/marvin + - web_assets:/usr/share/nginx/html + ports: + - 8080:80 + depends_on: + - marvin + networks: + - frontend + + redis: + container_name: redis + image: redis:latest + networks: + - backend + + marvin: + container_name: marvin + build: + context: .. + dockerfile: docker/Dockerfile.dev + args: + MARVIN_TAG: ${MARVIN_TAG:-main} + image: marvin:${MARVIN_TAG:-latest} + ports: + - 8000:8000 + volumes: + - ${SAS_BASE_DIR}:/root/sas/ + - $HOME/.pgpass:/root/.pgpass + - socket_logs:/tmp/marvin + - web_assets:/app/python/marvin/web + environment: + - SESSION_REDIS=redis://redis:6379 + - MARVIN_BASE=marvin + - PUBLIC_SERVER=True + - MANGADB_CONFIG=docker + networks: + - backend + - frontend + depends_on: + - redis + +networks: + backend: + frontend: + +volumes: + socket_logs: + web_assets: diff --git a/docker/gunicorn_config.py b/docker/gunicorn_config.py index 5979a895..f3d4139c 100644 --- a/docker/gunicorn_config.py +++ b/docker/gunicorn_config.py @@ -3,6 +3,8 @@ socket_dir = os.getenv("MARVIN_SOCKET_DIR", '/tmp/marvin') bind = [f"unix:{socket_dir}/marvin.sock", "0.0.0.0:8000"] workers = 1 +worker_class = "gthread" +threads = 8 daemon = False errorlog = os.path.join(os.getenv("MARVIN_LOGS_DIR", '/tmp/marvin/logs'), 'marvin_app_error.log') accesslog = os.path.join(os.getenv("MARVIN_LOGS_DIR", '/tmp/marvin/logs'), 'marvin_app_access.log') diff --git a/python/marvin/web/templates/header.html b/python/marvin/web/templates/header.html index 4d7ae4f4..189677e0 100644 --- a/python/marvin/web/templates/header.html +++ b/python/marvin/web/templates/header.html @@ -61,35 +61,6 @@ - {% elif not current_user.is_authenticated %} - - {# Login #} - - {% else %} - - {# User Preferences Post Login #} - {% endif %} diff --git a/python/marvin/web/web_utils.py b/python/marvin/web/web_utils.py index 80637aaa..97e5514a 100644 --- a/python/marvin/web/web_utils.py +++ b/python/marvin/web/web_utils.py @@ -43,14 +43,14 @@ def check_request_for_release(request): def configFeatures(app): ''' Configure Flask Feature Flags ''' - app.config['FEATURE_FLAGS']['public'] = True if config.access == 'public' else False + app.config['FEATURE_FLAGS']['public'] = True def check_access(): ''' Check the access mode in the session ''' # check if on public server - public_server = request.environ.get('PUBLIC_SERVER', None) == 'True' + public_server = request.environ.get('PUBLIC_SERVER', True) == 'True' public_flag = public_server or current_app.config['FEATURE_FLAGS']['public'] current_app.config['FEATURE_FLAGS']['public'] = public_server public_access = config.access == 'public' diff --git a/setup.cfg b/setup.cfg index 2509b41d..c1676dbb 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = sdss-marvin -version = 2.8.2 +version = 2.8.3dev author = The Marvin Developers author_email = havok2063@hotmail.com description = Toolsuite for dealing with the MaNGA dataset @@ -149,6 +149,7 @@ web= redis>=3.3 #uwsgi>=2.0.15 # install with "conda install -c conda-forge uwsgi" instead # added for rtd issues + marshmallow<4.0 validators>=0.10.3 intervals>=0.8.0 db=