Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add: first version of the bananas_server rewritten in Python #1

Merged
merged 4 commits into from Apr 20, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .Dockerignore
@@ -0,0 +1,5 @@
__pycache__/
*.pyc
/.env
/BaNaNaS
/local_storage
40 changes: 40 additions & 0 deletions .github/workflows/deployment.yml
@@ -0,0 +1,40 @@
name: Deployment

on:
deployment:

jobs:
deploy_to_aws:
name: Deploy to AWS
runs-on: ubuntu-latest

steps:
- name: Deployment in progress
uses: openttd/actions/deployments-update@v1
with:
github-token: ${{ secrets.DEPLOYMENT_TOKEN }}
state: in_progress
description: "Deployment of ${{ github.event.deployment.payload.version }} to ${{ github.event.deployment.environment }} started"

- name: Deploy on AWS
uses: openttd/actions/deploy-aws@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-region: ${{ secrets.AWS_REGION }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
name: BananasServer

- if: success()
name: Deployment successful
uses: openttd/actions/deployments-update@v1
with:
github-token: ${{ secrets.DEPLOYMENT_TOKEN }}
state: success
description: "Successfully deployed ${{ github.event.deployment.payload.version }} on ${{ github.event.deployment.environment }}"

- if: failure() || cancelled()
name: Deployment failed
uses: openttd/actions/deployments-update@v1
with:
github-token: ${{ secrets.DEPLOYMENT_TOKEN }}
state: failure
69 changes: 69 additions & 0 deletions .github/workflows/publish.yml
@@ -0,0 +1,69 @@
name: Publish image

on:
push:
branches:
- master
tags:
- '*'
repository_dispatch:
types:
- publish_latest_tag
- publish_master

jobs:
publish_image:
name: Publish image
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0

- if: github.event_name == 'repository_dispatch'
name: Repository dispatch
uses: openttd/actions/checkout-dispatch@v1

- name: Checkout tags and submodules
uses: openttd/actions/checkout@v1
with:
with-tags: true

- name: Set variables
id: vars
uses: openttd/actions/docker-vars@v1
with:
docker-hub-username: ${{ secrets.DOCKER_USERNAME }}

- name: Build
uses: openttd/actions/docker-build@v1
with:
name: ${{ steps.vars.outputs.name }}
tag: ${{ steps.vars.outputs.tag }}
tags: ${{ steps.vars.outputs.tags }}
version: ${{ steps.vars.outputs.version }}
date: ${{ steps.vars.outputs.date }}

- if: steps.vars.outputs.dry-run == 'false'
name: Publish
id: publish
uses: openttd/actions/docker-publish@v1
with:
docker-hub-username: ${{ secrets.DOCKER_USERNAME }}
docker-hub-password: ${{ secrets.DOCKER_PASSWORD }}
name: ${{ steps.vars.outputs.name }}
tag: ${{ steps.vars.outputs.tag }}

# Dorpsgek only runs on production, not on staging.
- if: steps.vars.outputs.dry-run == 'false' && steps.vars.outputs.environment == 'production'
name: Trigger deployment
uses: openttd/actions/deployments-create@v1
with:
ref: ${{ steps.vars.outputs.sha }}
environment: ${{ steps.vars.outputs.environment }}
version: ${{ steps.vars.outputs.version }}
date: ${{ steps.vars.outputs.date }}
docker-tag: ${{ steps.publish.outputs.remote-tag }}
github-token: ${{ secrets.DEPLOYMENT_TOKEN }}
4 changes: 2 additions & 2 deletions .github/workflows/testing.yml
Expand Up @@ -25,7 +25,7 @@ jobs:
- name: Flake8
uses: TrueBrain/actions-flake8@master
with:
path: content_server
path: bananas_server

black:
name: Black
Expand All @@ -41,4 +41,4 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install black
black -l 120 --check content_server
black -l 120 --check bananas_server
5 changes: 5 additions & 0 deletions .gitignore
@@ -0,0 +1,5 @@
__pycache__/
*.pyc
/.env
/BaNaNaS
/local_storage
1 change: 1 addition & 0 deletions .version
@@ -0,0 +1 @@
dev
34 changes: 34 additions & 0 deletions Dockerfile
@@ -1,2 +1,36 @@
FROM python:3.8-slim

ARG BUILD_DATE=""
ARG BUILD_VERSION="dev"

LABEL maintainer="truebrain@openttd.org"
LABEL org.label-schema.schema-version="1.0"
LABEL org.label-schema.build-date=${BUILD_DATE}
LABEL org.label-schema.version=${BUILD_VERSION}

RUN apt-get update && apt-get install -y --no-install-recommends \
git \
&& rm -rf /var/lib/apt/lists/*

WORKDIR /code

COPY requirements.txt \
LICENSE \
README.md \
.version \
/code/
# Needed for Sentry to know what version we are running
RUN echo "${BUILD_VERSION}" > /code/.version

RUN pip --no-cache-dir install -r requirements.txt

# Validate that what was installed was what was expected
RUN pip freeze 2>/dev/null > requirements.installed \
&& diff -u --strip-trailing-cr requirements.txt requirements.installed 1>&2 \
|| ( echo "!! ERROR !! requirements.txt defined different packages or versions for installation" \
&& exit 1 ) 1>&2

COPY bananas_server /code/bananas_server

ENTRYPOINT ["python", "-m", "bananas_server"]
CMD ["--bind", "0.0.0.0", "--storage", "local", "--index", "local"]