Skip to content

Commit

Permalink
Merge pull request #12 from Sage-Bionetworks/prepare-release
Browse files Browse the repository at this point in the history
Prepare release
  • Loading branch information
tschaffter authored Oct 6, 2020
2 parents 236c57e + 0cbed4e commit 7270a20
Show file tree
Hide file tree
Showing 45 changed files with 106 additions and 144 deletions.
41 changes: 26 additions & 15 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ on:
- cron: '0 10 * * *' # everyday at 10am
push:
branches:
- '**'
- main
- develop
tags:
- 'v*.*.*'
- '*.*.*'
pull_request:

jobs:
Expand All @@ -19,13 +20,19 @@ jobs:
uses: docker://hadolint/hadolint:latest
with:
entrypoint: hadolint
args: src/server/Dockerfile
args: server/Dockerfile
- name: Check that packages in requirements.txt files are in asc order
run: |
sort -f --check server/requirements.txt
sort -f --check server/test-requirements.txt
test:
needs: [lint]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Validate docker-compose.yml
run: docker-compose -f docker-compose.yml config >/dev/null
- name: Set up Python
uses: actions/setup-python@v2
with:
Expand All @@ -49,8 +56,10 @@ jobs:
run: |
DOCKER_IMAGE=nlpsandbox/date-annotator-example
VERSION=noop
PUSH=false
if [ "${{ github.event_name }}" = "schedule" ]; then
VERSION=nightly
PUSH=true
elif [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
elif [[ $GITHUB_REF == refs/heads/* ]]; then
Expand All @@ -62,22 +71,24 @@ jobs:
VERSION=pr-${{ github.event.number }}
fi
TAGS="${DOCKER_IMAGE}:${VERSION}"
if [[ $VERSION =~ ^v[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
if [[ $VERSION =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
MINOR=${VERSION%.*}
MAJOR=${MINOR%.*}
TAGS="$TAGS,${DOCKER_IMAGE}:${MINOR},${DOCKER_IMAGE}:${MAJOR},${DOCKER_IMAGE}:latest"
PUSH=true
elif [ "${{ github.event_name }}" = "push" ]; then
TAGS="$TAGS,${DOCKER_IMAGE}:sha-${GITHUB_SHA::8}"
fi
echo ::set-output name=version::${VERSION}
echo ::set-output name=tags::${TAGS}
echo ::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ')
echo ::set-output name=push::${PUSH}
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
if: github.event_name != 'pull_request'
if: ${{ steps.prep.outputs.push }}
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
Expand All @@ -86,14 +97,14 @@ jobs:
id: docker_build
uses: docker/build-push-action@v2
with:
context: src/server
file: src/server/Dockerfile
platforms: linux/amd64,linux/arm64,linux/386
push: ${{ github.event_name != 'pull_request' }}
context: server
file: server/Dockerfile
platforms: linux/amd64
push: ${{ steps.prep.outputs.push }}
tags: ${{ steps.prep.outputs.tags }}
# labels: |
# org.opencontainers.image.created=${{ steps.prep.outputs.created }}
# org.opencontainers.image.source=${{ github.repositoryUrl }}
# org.opencontainers.image.version=${{ steps.prep.outputs.version }}
# org.opencontainers.image.revision=${{ github.sha }}
# org.opencontainers.image.licenses=${{ github.event.repository.license.name }}
labels: |
org.opencontainers.image.created=${{ steps.prep.outputs.created }}
org.opencontainers.image.source=${{ github.repositoryUrl }}
org.opencontainers.image.version=${{ steps.prep.outputs.version }}
org.opencontainers.image.revision=${{ github.sha }}
org.opencontainers.image.licenses=${{ github.event.repository.license.name }}
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# Dir for bundles
dist
node_modules
.idea
venv
venv
5 changes: 0 additions & 5 deletions .vscode/extensions.json

This file was deleted.

5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
# nlp-sandbox-date-annotator-example

[![GitHub Stars](https://img.shields.io/github/stars/data2health/nlp-sandbox-date-annotator-example.svg?color=94398d&labelColor=555555&logoColor=ffffff&style=for-the-badge&logo=github)](https://github.com/data2health/nlp-sandbox-date-annotator-example)
[![Docker Pulls](https://img.shields.io/docker/pulls/nlpsandbox/date-annotator-example.svg?color=94398d&labelColor=555555&logoColor=ffffff&style=for-the-badge&label=pulls&logo=docker)](https://hub.docker.com/r/data2health/nlp-sandbox-date-annotator-example)
[![GitHub CI](https://img.shields.io/github/workflow/status/data2health/nlp-sandbox-date-annotator-example/ci.svg?color=94398d&labelColor=555555&logoColor=ffffff&style=for-the-badge&logo=github)](https://github.com/data2health/nlp-sandbox-date-annotator-example)
[![GitHub License](https://img.shields.io/github/license/data2health/nlp-sandbox-date-annotator-example.svg?color=94398d&labelColor=555555&logoColor=ffffff&style=for-the-badge&logo=github)](https://github.com/data2health/nlp-sandbox-date-annotator-example)
<!-- [![GitHub Release](https://img.shields.io/github/release/data2health/nlp-sandbox-date-annotator-example.svg?color=94398d&labelColor=555555&logoColor=ffffff&style=for-the-badge&logo=github)](https://github.com/data2health/nlp-sandbox-date-annotator-example/releases) -->
<!-- [![Docker Stars](https://img.shields.io/docker/stars/nlpsandbox/date-annotator-example.svg?color=94398d&labelColor=555555&logoColor=ffffff&style=for-the-badge&label=stars&logo=docker)](https://hub.docker.com/r/data2health/nlp-sandbox-date-annotator-example) -->

An example implementation of the NLP Sandbox Date Annotator
An example implementation of the NLP Sandbox Date Annotator.

## Development

Expand Down
11 changes: 11 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: "3.8"

services:
date-annotator:
image: nlpsandbox/date-annotator-example:latest
build:
context: server
dockerfile: Dockerfile
container_name: date-annotator-example
ports:
- "8080:8080"
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nlp-sandbox-date-annotator-example",
"version": "1.0.0-beta.1",
"version": "1.0.0",
"license": "Apache-2.0",
"repository": "github:data2health/nlp-sandbox-date-annotator-example",
"devDependencies": {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
45 changes: 45 additions & 0 deletions server/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
FROM python:3.8.5-slim-buster

ARG S6_VERSION
ENV S6_VERSION=${S6_VERSION:-v2.1.0.0}
ENV S6_BEHAVIOUR_IF_STAGE2_FAILS=2
ENV PIP_NO_CACHE_DIR=off
ENV APP_USER=app
ENV APP_DIR=/opt/app

# Safer bash scripts with 'set -euxo pipefail'
SHELL ["/bin/bash", "-euxo", "pipefail", "-c"]

# Install dependencies
# hadolint ignore=DL3008
RUN apt-get update -qq -y \
&& apt-get install --no-install-recommends -qq -y \
curl \
unzip \
&& apt-get -y autoclean \
&& apt-get -y autoremove \
&& rm -rf /var/lib/apt/lists/*

# Set up S6 init system
RUN curl -fsSL https://github.com/just-containers/s6-overlay/releases/download/${S6_VERSION}/s6-overlay-amd64.tar.gz \
-o /tmp/s6-overlay.tar.gz \
&& tar xzf /tmp/s6-overlay.tar.gz --directory / \
&& rm -fr /tmp/s6-overlay.tar.gz

# Add app user
RUN useradd -m -s /bin/bash ${APP_USER} \
&& echo "${APP_USER}:${APP_USER}" | chpasswd

# Copy server files
COPY . ${APP_DIR}
RUN chown -R ${APP_USER}:${APP_USER} ${APP_DIR}

# Install dependencies
RUN pip install -r ${APP_DIR}/requirements.txt

# Add s6 scripts
COPY root /

EXPOSE 8080

ENTRYPOINT ["/init"]
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 4 additions & 0 deletions server/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
connexion==2.7.0
requests==2.24.0
swagger-ui-bundle==0.0.8
synapseclient==2.2.0
4 changes: 4 additions & 0 deletions server/root/etc/cont-init.d/20-create-app-logfolder
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh

mkdir -p /var/log/app
chown nobody:nogroup /var/log/app
5 changes: 5 additions & 0 deletions server/root/etc/services.d/app/finish
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/execlineb -S0

# By default, services created in /etc/services.d will automatically restart.
# Here we bring the container down if a service crashes.
s6-svscanctl -t /var/run/s6/services
4 changes: 4 additions & 0 deletions server/root/etc/services.d/app/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/with-contenv sh

cd /opt/app
s6-setuidgid app python -m openapi_server
File renamed without changes.
4 changes: 4 additions & 0 deletions server/test-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Flask-Testing==0.8.0
pytest-cov>=2.8.1
pytest-randomly==3.4.1 # needed for python 2.7+3.4
pytest~=6.1.1 # needed for python 2.7+3.4
File renamed without changes.
14 changes: 0 additions & 14 deletions src/server/.travis.yml

This file was deleted.

16 changes: 0 additions & 16 deletions src/server/Dockerfile

This file was deleted.

58 changes: 0 additions & 58 deletions src/server/git_push.sh

This file was deleted.

24 changes: 0 additions & 24 deletions src/server/requirements.txt

This file was deleted.

4 changes: 0 additions & 4 deletions src/server/test-requirements.txt

This file was deleted.

0 comments on commit 7270a20

Please sign in to comment.