Skip to content

Commit

Permalink
Merge pull request #8 from LCOGT/feature/open-source
Browse files Browse the repository at this point in the history
Open Source Simbad2k
  • Loading branch information
mgdaily authored May 11, 2022
2 parents d92f528 + 306f7dd commit c18c093
Show file tree
Hide file tree
Showing 25 changed files with 1,358 additions and 396 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Build

on:
# Run this workflow for pushes on all branches
push:
branches:
- '**'
# Run this workflow when a tag or branch is created
create:
# Run this workflow for pull requests
pull_request:

jobs:
run_tests:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10"]
steps:
- name: Check out repository
uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install poetry
poetry install
- name: Run tests
run: poetry run pytest
88 changes: 88 additions & 0 deletions .github/workflows/publish-docker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: Push Docker Image

on:
push:
branches:
- "main"
# Publish semver tags as releases.
tags:
- "*.*.*"
pull_request:
branches: [ main ]

env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}


jobs:
build:

runs-on: ubuntu-latest
permissions:
contents: read
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write

steps:
- name: Checkout repository
uses: actions/checkout@v2

# Install the cosign tool except on PR
# https://github.com/sigstore/cosign-installer
- name: Install cosign
if: github.event_name != 'pull_request'
uses: sigstore/cosign-installer@1e95c1de343b5b0c23352d6417ee3e48d5bcd422
with:
cosign-release: 'v1.4.0'


# Workaround: https://github.com/docker/build-push-action/issues/461
- name: Setup Docker buildx
uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf

# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/[email protected]
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

# Sign the resulting Docker image digest except on PRs.
# This will only write to the public Rekor transparency log when the Docker
# repository is public to avoid leaking data. If you would like to publish
# transparency data even for private images, pass --force to cosign below.
# https://github.com/sigstore/cosign
- name: Sign the published Docker image
if: ${{ github.event_name != 'pull_request' }}
env:
COSIGN_EXPERIMENTAL: "true"
# This step uses the identity token to provision an ephemeral certificate
# against the sigstore community Fulcio instance.
run: cosign sign ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ steps.build-and-push.outputs.digest }}
23 changes: 16 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
FROM python:3.8-slim
FROM python:3.10-alpine

SHELL ["/bin/sh", "-c"]

WORKDIR /app

COPY ./pyproject.toml ./poetry.lock ./

# install Python dependencies
COPY requirements.txt .
RUN apt update && apt install openssl \
&& pip install --upgrade 'pip>=19.0.2' \
&& pip --no-cache-dir install -r requirements.txt \
&& apt clean
RUN apk update && apk --no-cache add --virtual .build_deps gcc g++ libffi-dev openssl \
&& pip install --upgrade pip && pip install poetry \
&& pip install -r <(poetry export | grep "numpy") \
&& pip install -r <(poetry export) \
&& apk --no-cache del .build_deps

# install application
COPY . .

# Flush logs and handle signals properly
ENV PYTHONUNBUFFERED=1 PYTHONFAULTHANDLER=1

EXPOSE 5000

# default command
CMD [ "gunicorn", "--worker-class=gevent", "--bind=0.0.0.0:5000", "--access-logfile=-", "--error-logfile=-", "simbad2k:app" ]
CMD [ "gunicorn", "--worker-class=gevent", "--bind=0.0.0.0:5000", "--access-logfile=-", "--error-logfile=-", "simbad2k.simbad2k:app" ]
1 change: 0 additions & 1 deletion Jenkinsfile

This file was deleted.

29 changes: 8 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,30 +31,17 @@ and `mpc_comet`. Examples of three queries are as follows:

## Development

Create a virtual environment and install app dependencies:
```
python3.8 -m venv env3
source env3/bin/activate
pip install -r requirements.txt
pip install -r tests/test_requirements.txt
```bash
python3 -m pip install --user pipx
python3 -m pipx ensurepath
pipx install poetry
```

Run the tests:
```
pytest
```
`poetry install` will create a virtual environment for you, which will have all requirements installed.

Run the tests with `poetry run pytest`.

Run the development server:
```
FLASK_DEBUG=1 FLASK_APP=simbad2k.py flask run
FLASK_DEBUG=1 FLASK_APP=simbad2k.simbad2k.py poetry run flask run
```

## Build

This project is built by the [LCO Jenkins Server](http://jenkins.lco.gtn/).
Please see the [Jenkinsfile](Jenkinsfile) for details.

## Production Deployment

This project is deployed on the LCO Kubernetes Cluster. Please see the
associated [Helm chart](https://github.com/LCOGT/helm-charts/) for details.
22 changes: 0 additions & 22 deletions helm-chart/.helmignore

This file was deleted.

5 changes: 0 additions & 5 deletions helm-chart/Chart.yaml

This file was deleted.

21 changes: 0 additions & 21 deletions helm-chart/templates/NOTES.txt

This file was deleted.

58 changes: 0 additions & 58 deletions helm-chart/templates/_helpers.tpl

This file was deleted.

92 changes: 0 additions & 92 deletions helm-chart/templates/deployment.yaml

This file was deleted.

Loading

0 comments on commit c18c093

Please sign in to comment.