Skip to content

Commit d836bb1

Browse files
Merge pull request #1 from simonsobs/koopman/dockerize-server
Create Dockerfile and workflow to build and push images
2 parents e78b683 + 677dd72 commit d836bb1

File tree

10 files changed

+2972
-2
lines changed

10 files changed

+2972
-2
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
src/scheduler_server/_version.py export-subst

.github/workflows/build.yaml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Publish Images to Container Registries
2+
3+
on:
4+
release:
5+
types: [ released ]
6+
pull_request:
7+
8+
jobs:
9+
docker:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: read
13+
packages: write
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v3
17+
18+
- name: Determine Docker tag
19+
run: |
20+
DOCKER_TAG=`git describe --tags --always`
21+
echo "docker_tag=${DOCKER_TAG}" >> "$GITHUB_ENV"
22+
23+
- name: Set up Docker Buildx
24+
uses: docker/setup-buildx-action@v2
25+
26+
- name: Login to Docker Hub
27+
uses: docker/login-action@v2
28+
with:
29+
username: ${{ secrets.DOCKERHUB_USERNAME }}
30+
password: ${{ secrets.DOCKERHUB_TOKEN }}
31+
32+
- name: Login to GitHub Container Registry
33+
uses: docker/login-action@v2
34+
with:
35+
registry: ghcr.io
36+
username: ${{ github.repository_owner }}
37+
password: ${{ secrets.GITHUB_TOKEN }}
38+
39+
- name: Build and push
40+
uses: docker/build-push-action@v4
41+
with:
42+
context: .
43+
push: ${{ github.event_name != 'pull_request' }}
44+
tags: |
45+
simonsobs/scheduler-server:latest
46+
simonsobs/scheduler-server:${{ env.docker_tag }}
47+
ghcr.io/simonsobs/scheduler-server:latest
48+
ghcr.io/simonsobs/scheduler-server:${{ env.docker_tag }}
49+

Dockerfile

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# scheduler-server
2+
3+
# Use ubuntu base image
4+
FROM ubuntu:22.04
5+
6+
WORKDIR /app
7+
8+
# Ensure we're set to UTC
9+
ENV TZ=Etc/UTC
10+
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
11+
12+
# Install python
13+
RUN apt-get update && apt-get install -y python3 \
14+
python3-pip \
15+
git
16+
17+
# Install dumb-init
18+
RUN pip install dumb-init
19+
20+
# Copy in and install requirements
21+
# This will leverage the cache for rebuilds when modifying the code, avoiding
22+
# downloading all the requirements again
23+
COPY requirements.txt /app/requirements.txt
24+
RUN pip3 install -r requirements.txt
25+
26+
# Install schedlib
27+
COPY . .
28+
RUN pip install .
29+
30+
# Run server
31+
EXPOSE 8010
32+
ENTRYPOINT ["dumb-init", "gunicorn", "--bind", "0.0.0.0:8010", "scheduler_server.app:app"]

readme.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,21 @@
33
## Installation
44
First clone this repository, and then install it with
55
```bash
6+
pip install -r requirements.txt
67
pip install -e .
78
```
89
## Launch
910
Launching it requires `gunicorn` to be available. If we are inside this directory, run
1011
```bash
1112
gunicorn --bind localhost:8010 scheduler_server.app:app
1213
```
14+
15+
### Docker
16+
Alternatively, you can launch the server in a docker container:
17+
```bash
18+
docker run --rm -p 8010:8010 scheduler-server
19+
```
20+
1321
## Schedule API
1422
The API is temporarily hosted here: https://scheduler-uobd.onrender.com
1523

requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
flask
22
flask_cors
33
gunicorn
4+
numpy
45
pyyaml
56
pandas
7+
schedlib @ git+https://github.com/simonsobs/scheduler.git@main

setup.cfg

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[versioneer]
2+
VCS = git
3+
style = pep440
4+
versionfile_source = src/scheduler_server/_version.py
5+
versionfile_build = scheduler_server/_version.py
6+
tag_prefix = v
7+
parentdir_prefix = scheduler-server-

setup.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
11
import setuptools
22

3+
import versioneer
4+
35
setuptools.setup(
46
name="scheduler_server",
5-
version="0.1.0",
7+
version=versioneer.get_version(),
8+
cmdclass=versioneer.get_cmdclass(),
69
author="Yilun Guan",
710
author_email="yilun.guan@utoronto.ca",
811
description="scheduler server",
912
packages=setuptools.find_packages(where="src"),
1013
package_dir={"": "src"},
1114
package_data={
12-
"scheduler_server": ["config.yaml", "*.txt"],
15+
"scheduler_server": [
16+
"configs/*.txt",
17+
],
1318
},
1419
classifiers=[
1520
"Development Status :: 3 - Alpha",

src/scheduler_server/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
from . import _version
3+
__version__ = _version.get_versions()['version']

0 commit comments

Comments
 (0)