Commit 0d803bee authored by William Roberts's avatar William Roberts
Browse files

Add first attempt at RU server

parent 766fa048
Pipeline #36579 passed with stage
in 7 minutes and 21 seconds
ARG ENV_NAME=env
FROM condaforge/mambaforge:4.11.0-0 as environment
RUN apt-get update
RUN mamba install -y --strict-channel-priority -c conda-forge conda-pack
ARG ENV_NAME
ENV ENV_NAME=$ENV_NAME
RUN mamba create -y -n ${ENV_NAME}
RUN conda-pack -n ${ENV_NAME} -o /${ENV_NAME}.tar &&\
mkdir /${ENV_NAME} && cd /${ENV_NAME} && tar xf /${ENV_NAME}.tar &&\
/${ENV_NAME}/bin/conda-unpack
RUN mamba install -y -p /${ENV_NAME} --strict-channel-priority -c conda-forge python=3.8 flask markdown
FROM gitlab.ssec.wisc.edu:5555/cris_l1b/user/develop
ARG ENV_NAME
ENV ENV_NAME=$ENV_NAME
COPY --from=environment /$ENV_NAME /$ENV_NAME
RUN echo 'source /$ENV_NAME/bin/activate' > ~/.bashrc
RUN echo 'exec "$@"' > /entrypoint.sh
# --login runs ~/.bashrc which sources /env
ENTRYPOINT ["bash", "--login", "/entrypoint.sh"]
COPY ru_server.py /app/ru_server.py
COPY README.md /README.md
WORKDIR /app
#RUN chmod a+xwr /
CMD ["python", "ru_server.py"]
Example:
curl --output out.mat 'cris-l1b-ru-test.ssec.wisc.edu/SNDR.SNPP.CRIS.20190806T0312.m06.g033.L1B.std.vXX_XX_XX.T.200529014740.nc'
from flask import Flask, make_response, request, send_from_directory
import subprocess
import markdown
app = Flask(__name__)
@app.route('/', methods=['GET'])
def readme():
if request.method == 'GET':
readme_file = open("/README.md", "r")
md_template_string = markdown.markdown(
readme_file.read(), extensions=["fenced_code"]
)
return md_template_string
@app.route('/<granule>', methods=['GET'])
def main(granule):
subprocess.check_output(['bash', '-c', f'cris-l1b-ru SNPP /input/{granule} /output'])
return send_from_directory('/output/', f'{granule.replace(".nc", "")}_RUopts.mat', as_attachment=True)
if __name__ == '__main__':
app.run(host="0.0.0.0", port=5432, debug=True)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment