Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Brennaser committed Jul 24, 2023
2 parents be4cf10 + f1ac756 commit 43cfa97
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 9 deletions.
17 changes: 12 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,26 @@ jobs:
docker_layer_caching: false
resource_class: arm.medium
steps:
- run: |
echo "export REPO_NAME=$(printf '%s\n' \"${CIRCLE_PROJECT_REPONAME,,}\")" >> $BASH_ENV && \
echo "export USER=$(printf '%s\n' \"${CIRCLE_PROJECT_USERNAME,,}\")" >> $BASH_ENV
- checkout
- run:
name: Setup Custom Environment Variables & Add Version
command: |
echo "export REPO_NAME=$(printf '%s\n' \"${CIRCLE_PROJECT_REPONAME,,}\")" >> $BASH_ENV && \
echo "export USER=$(printf '%s\n' \"${CIRCLE_PROJECT_USERNAME,,}\")" >> $BASH_ENV && \
export VERSION=${CIRCLE_TAG:-NIGHTLY.$(date --rfc-3339=seconds | sed 's/[ :+]/-/g')} && \
echo "export VERSION=$VERSION" >> $BASH_ENV && \
echo $VERSION > version.txt
- docker/check:
docker-username: CIRCLE_PROJECT_USERNAME
registry: ghcr.io
- docker/build:
image: $USER/$REPO_NAME
tag: ${VERSION:-latest}
tag: $VERSION
registry: ghcr.io
- docker/push:
digest-path: /tmp/digest.txt
image: $USER/$REPO_NAME
tag: ${VERSION:-latest}
tag: $VERSION
registry: ghcr.io
- run:
command: |
Expand All @@ -32,5 +37,7 @@ workflows:
jobs:
- build-and-push:
filters:
branches:
only: main
tags: # see: https://circleci.com/blog/publishing-to-github-releases-via-circleci/
only: /(?<=^[Vv]|^)(?:(?<major>(?:0|[1-9](?:(?:0|[1-9])+)*))[.](?<minor>(?:0|[1-9](?:(?:0|[1-9])+)*))[.](?<patch>(?:0|[1-9](?:(?:0|[1-9])+)*))(?:-(?<prerelease>(?:(?:(?:[A-Za-z]|-)(?:(?:(?:0|[1-9])|(?:[A-Za-z]|-))+)?|(?:(?:(?:0|[1-9])|(?:[A-Za-z]|-))+)(?:[A-Za-z]|-)(?:(?:(?:0|[1-9])|(?:[A-Za-z]|-))+)?)|(?:0|[1-9](?:(?:0|[1-9])+)*))(?:[.](?:(?:(?:[A-Za-z]|-)(?:(?:(?:0|[1-9])|(?:[A-Za-z]|-))+)?|(?:(?:(?:0|[1-9])|(?:[A-Za-z]|-))+)(?:[A-Za-z]|-)(?:(?:(?:0|[1-9])|(?:[A-Za-z]|-))+)?)|(?:0|[1-9](?:(?:0|[1-9])+)*)))*))?(?:[+](?<build>(?:(?:(?:[A-Za-z]|-)(?:(?:(?:0|[1-9])|(?:[A-Za-z]|-))+)?|(?:(?:(?:0|[1-9])|(?:[A-Za-z]|-))+)(?:[A-Za-z]|-)(?:(?:(?:0|[1-9])|(?:[A-Za-z]|-))+)?)|(?:(?:0|[1-9])+))(?:[.](?:(?:(?:[A-Za-z]|-)(?:(?:(?:0|[1-9])|(?:[A-Za-z]|-))+)?|(?:(?:(?:0|[1-9])|(?:[A-Za-z]|-))+)(?:[A-Za-z]|-)(?:(?:(?:0|[1-9])|(?:[A-Za-z]|-))+)?)|(?:(?:0|[1-9])+)))*))?)$/
6 changes: 5 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM python:3.10-slim-bullseye as base

RUN apt update && apt install wget tar git libpcrecpp0v5 -y
RUN apt update && apt install wget tar git -y

WORKDIR /app

Expand All @@ -14,6 +14,8 @@ RUN pip3 install --no-index --find-links=/app/packages -r /app/scripts/requireme

FROM python:3.10-slim-bullseye

RUN apt update && apt install libpcrecpp0v5 -y

WORKDIR /app

# copy pip packages from base
Expand All @@ -23,6 +25,8 @@ COPY --from=base /usr/local/bin/gunicorn /usr/local/bin/gunicorn

COPY ./*.py /app/

COPY ./*.txt /app/

COPY ./scripts/download_hitran.py .

CMD gunicorn --bind 0.0.0.0:5000 wsgi:app
12 changes: 9 additions & 3 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,18 @@

app = Flask(__name__)
CORS(app)

try:
with open("version.txt","r") as f:
version = f.read()
app.config["VERSION"] = version
except:
print("no version file found")

@app.route("/", methods=["GET"])
def ftir() -> str:
return "<h1 style='color:blue'>Raston Lab FTIR API</h1>"

if "VERSION" not in app.config:
app.config["VERSION"] = "0.0.0"
return "<h1 style='color:blue'>Raston Lab FTIR API%s</h1>" % (" - Version "+app.config["VERSION"])

@app.route("/spectrum", methods=["POST"])
def spectrum() -> dict[bool, list[float], list[float]]:
Expand Down

0 comments on commit 43cfa97

Please sign in to comment.