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
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
**/*.pyc
**/*__pycache__
96 changes: 96 additions & 0 deletions .github/workflows/publish-docker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
name: Publish Docker Image

on:
push:
branches:
- main
- mvp # TODO: remove after testing
# Publish semver tags as releases.
tags:
- '*.*.*'
pull_request:
branches:
- main

env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
Comment thread
jashan-lco marked this conversation as resolved.
# 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/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=schedule
type=ref,event=branch
type=ref,event=tag
type=ref,event=pr
type=raw,value=latest,enable=${{ endsWith(github.ref, github.event.repository.default_branch) }}

# 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 }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
**/*.pyc
**/*__pycache__
19 changes: 19 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM python:3.10-slim

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

RUN pip install poetry

WORKDIR /src

COPY pyproject.toml poetry.lock README.rst ./

RUN pip install -r <(poetry export)

COPY ./virtual_site.py ./virtual_site.py

RUN pip install .

ENV PYTHONUNBUFFERED=true

ENTRYPOINT ["virtual-site"]
31 changes: 31 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
virtual-site
####
Comment thread
jashan-lco marked this conversation as resolved.

Example application showcasing OCS API interactions needed to fulfill
observation requests at a telescope site.

You might find this helpful if you're looking to integrate your telescope's
control system with the Observatory Control System. Also, see
https://observatorycontrolsystem.github.io/integration/tcs/.

Usage
----

You can spin up the client straight from docker::

$ docker run ghcr.io/observatorycontrolsystem/virtual-site --help
$ docker run ghcr.io/observatorycontrolsystem/virtual-site \
--name ogg \
--api-url http://localhost:8000/api/ \
--api-token 'sutoken1234abcd'

Development
----

Install dependencies::

$ poetry install

Run::

$ poetry run virtual-site --name ogg --api-url http://localhost:8000/api/ --api-token 'sutoken1234abcd'
223 changes: 223 additions & 0 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[tool.poetry]
name = "virtual-site"
version = "0.1.0"
description = "Virtual OCS Site"
authors = ["Jashandeep Sohi <jsohi.lco.global>"]

[tool.poetry.dependencies]
python = "^3.10"
click = "^8.0.3"
httpx = "^0.21.3"
arrow = "^1.2.1"

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

[tool.poetry.scripts]
virtual-site = "virtual_site:cli"
Loading