Skip to content
Snippets Groups Projects
Commit e7d2ec48 authored by Jeremy M Fee's avatar Jeremy M Fee
Browse files

Update environment, use root_path instead of openapi_path, update gunicorn config

parent 54eed6b6
No related branches found
No related tags found
No related merge requests found
...@@ -4,11 +4,11 @@ FROM ${FROM_IMAGE} ...@@ -4,11 +4,11 @@ FROM ${FROM_IMAGE}
LABEL maintainer="Jeremy Fee <jmfee@usgs.gov>" LABEL maintainer="Jeremy Fee <jmfee@usgs.gov>"
# set environment variables # set environment variables
ENV PATH /conda/bin:$PATH \ ENV LANG='en_US.UTF-8' \
LC_ALL='en_US.UTF-8' \ LC_ALL='en_US.UTF-8' \
LANG='en_US.UTF-8' \ PATH=/conda/bin:$PATH \
PYTHONDONTWRITEBYTECODE 1 \ PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED 1 PYTHONUNBUFFERED=1
# install conda # install conda
RUN echo 'export PATH=/conda/bin:$PATH' > /etc/profile.d/conda.sh \ RUN echo 'export PATH=/conda/bin:$PATH' > /etc/profile.d/conda.sh \
...@@ -24,8 +24,9 @@ RUN conda config --set ssl_verify $SSL_CERT_FILE \ ...@@ -24,8 +24,9 @@ RUN conda config --set ssl_verify $SSL_CERT_FILE \
&& conda install --yes jupyter obspy pycurl \ && conda install --yes jupyter obspy pycurl \
&& conda clean --all -y \ && conda clean --all -y \
&& export PIP_CERT=$SSL_CERT_FILE \ && export PIP_CERT=$SSL_CERT_FILE \
&& pip install pipenv \ && pip install pipenv 'virtualenv!=20.0.22' \
&& yum install -y which && yum clean all && yum install -y which \
&& yum clean all
RUN useradd \ RUN useradd \
-c 'Docker image user' \ -c 'Docker image user' \
......
This diff is collapsed.
version: '3' version: '3'
services: services:
web: web:
image: usgs/geomag-algorithms:latest build: .
environment: environment:
- DATA_HOST=cwbpub.cr.usgs.gov # - DATA_HOST=cwbpub.cr.usgs.gov
- DATA_PORT=2060 # - DATA_PORT=2060
- DATA_TYPE=edge # - DATA_TYPE=edge
- GEOMAG_WEBSERVICE_PORT=8000 # - GEOMAG_WEBSERVICE_PORT=8000
- GEOMAG_VERSION=0.3.1 # - GEOMAG_VERSION=0.3.1
- WEBSERVICE=true - WEBSERVICE=true
ports: ports:
- '8000:8000' - '8000:8000'
#! /bin/bash #! /bin/bash
# Environment variable to determine whether to start webservice # Environment variable to determine whether to start webservice
export WEBSERVICE=${WEBSERVICE:-false} export WEBSERVICE=${WEBSERVICE:-false}
# add geomagio to notebook path # add geomagio to notebook path
export PYTHONPATH=/geomag-algorithms export PYTHONPATH=/geomag-algorithms
if [ $WEBSERVICE = 'false' ]; then if [ $WEBSERVICE = 'false' ]; then
# run jupyter notebook server # run jupyter notebook server
exec jupyter notebook \ exec jupyter notebook \
--ip='*' \ --ip='*' \
--notebook-dir=/data \ --notebook-dir=/data \
--no-browser \ --no-browser \
--port=8000 --port=8000
else else
# run gunicorn server for web service # run gunicorn server for web service
exec pipenv run gunicorn \ exec pipenv run gunicorn \
--bind 0.0.0.0:8000 \ --access-logfile - \
-w 4 \ --bind 0.0.0.0:8000 \
-k uvicorn.workers.UvicornWorker geomagio.api.app:app --threads 2 \
--workers 2 \
--worker-class uvicorn.workers.UvicornWorker \
--worker-tmp-dir /dev/shm \
geomagio.api:app
fi fi
...@@ -11,7 +11,7 @@ from .metadata import router as metadata_router ...@@ -11,7 +11,7 @@ from .metadata import router as metadata_router
from .SessionMiddleware import SessionMiddleware from .SessionMiddleware import SessionMiddleware
app = FastAPI() app = FastAPI(root_path="/ws/secure")
# NOTE: database used for sessions is started by ..app.app, # NOTE: database used for sessions is started by ..app.app,
# which mounts this application at /ws/secure # which mounts this application at /ws/secure
......
import os
from typing import Dict, Union from typing import Dict, Union
from fastapi import FastAPI, Request, Response from fastapi import FastAPI, Request, Response
...@@ -19,10 +20,10 @@ ERROR_CODE_MESSAGES = { ...@@ -19,10 +20,10 @@ ERROR_CODE_MESSAGES = {
503: "Service Unavailable", 503: "Service Unavailable",
} }
VERSION = "version" VERSION = os.getenv("GEOMAG_VERSION", "version")
app = FastAPI(docs_url="/docs", openapi_prefix="/ws") app = FastAPI(docs_url="/docs", root_path="/ws")
app.add_middleware(CORSMiddleware, allow_origins=["*"], max_age=86400) app.add_middleware(CORSMiddleware, allow_origins=["*"], max_age=86400)
......
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