Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,26 @@ jobs:
docker_layer_caching: false
resource_class: arm.medium
steps:
- checkout
- run:
name: Setup Custom Environment Variables
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 && \
echo "export VERSION=$CIRCLE_TAG" >> $BASH_ENV && \
echo "export TIMESTAMP=$(date --rfc-3339=seconds | sed 's/[ :+]/-/g')" >> $BASH_ENV
- checkout
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:-NIGHTLY.$TIMESTAMP}
tag: $VERSION
registry: ghcr.io
- docker/push:
digest-path: /tmp/digest.txt
image: $USER/$REPO_NAME
tag: ${VERSION:-NIGHTLY.$TIMESTAMP}
tag: $VERSION
registry: ghcr.io
- run:
command: |
Expand Down
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,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