generated from ghga-de/microservice-repository-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 9668894
Showing
78 changed files
with
6,969 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Please only mention the non-default settings here: | ||
|
||
language: Greek | ||
service_instance_id: "1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
FROM mcr.microsoft.com/vscode/devcontainers/python:3.9-bullseye | ||
|
||
ENV PYTHONUNBUFFERED 1 | ||
|
||
# Update args in docker-compose.yaml to set the UID/GID of the "vscode" user. | ||
ARG USER_UID=1000 | ||
ARG USER_GID=$USER_UID | ||
RUN if [ "$USER_GID" != "1000" ] || [ "$USER_UID" != "1000" ]; then groupmod --gid $USER_GID vscode && usermod --uid $USER_UID --gid $USER_GID vscode; fi | ||
|
||
# [Option] Install Node.js | ||
ARG INSTALL_NODE="true" | ||
ARG NODE_VERSION="lts/*" | ||
RUN if [ "${INSTALL_NODE}" = "true" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi | ||
|
||
# Copy install and launcher script to bin: | ||
COPY ./dev_install /bin | ||
COPY ./dev_launcher /bin | ||
|
||
CMD ["sleep", "infinity"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/bash | ||
# install service in dev container | ||
|
||
cd /workspace | ||
|
||
# upgrade pip | ||
python -m pip install --upgrade pip | ||
|
||
# install or upgrade dependencies for development and testing | ||
pip install --no-deps -r ./lock/requirements-dev.txt | ||
|
||
# install the package itself in edit mode: | ||
pip install --no-deps -e . | ||
|
||
# install pre-commit hooks to git | ||
pre-commit install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/bash | ||
|
||
# adapt to package name | ||
my-microservice |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at: | ||
// https://github.com/microsoft/vscode-dev-containers/tree/v0.177.0/containers/python-3-postgres | ||
// Update the VARIANT arg in docker-compose.yml to pick a Python version: 3, 3.8, 3.7, 3.6 | ||
{ | ||
"name": "${localWorkspaceFolderBasename}", | ||
"dockerComposeFile": "docker-compose.yml", | ||
"service": "app", | ||
"workspaceFolder": "/workspace", | ||
"customizations": { | ||
"vscode": { | ||
// Set *default* container specific settings.json values on container create. | ||
"settings": { | ||
"files.eol": "\n", | ||
"terminal.integrated.profiles.linux": { | ||
"bash": { | ||
"path": "/bin/bash" | ||
} | ||
}, | ||
"python.pythonPath": "/usr/local/bin/python", | ||
"python.languageServer": "Pylance", | ||
"python.analysis.typeCheckingMode": "basic", | ||
"python.testing.pytestPath": "/usr/local/py-utils/bin/pytest", | ||
"python.testing.pytestArgs": [ | ||
"--profile" | ||
], | ||
"python.testing.unittestEnabled": false, | ||
"python.testing.pytestEnabled": true, | ||
"editor.codeActionsOnSave": { | ||
"source.organizeImports": true | ||
}, | ||
"editor.formatOnSave": true, | ||
"editor.renderWhitespace": "all", | ||
"editor.rulers": [ | ||
88 | ||
], | ||
"ruff.organizeImports": true, | ||
"editor.defaultFormatter": "charliermarsh.ruff", | ||
"licenser.license": "Custom", | ||
"licenser.customHeaderFile": "/workspace/.devcontainer/license_header.txt" | ||
}, | ||
// Add the IDs of extensions you want installed when the container is created. | ||
"extensions": [ | ||
"mikestead.dotenv", | ||
"ms-azuretools.vscode-docker", | ||
"ms-python.python", | ||
"ms-python.vscode-pylance", | ||
"ms-toolsai.jupyter", | ||
"njpwerner.autodocstring", | ||
"redhat.vscode-yaml", | ||
"42crunch.vscode-openapi", | ||
"arjun.swagger-viewer", | ||
"eamodio.gitlens", | ||
"github.vscode-pull-request-github", | ||
"streetsidesoftware.code-spell-checker", | ||
"yzhang.markdown-all-in-one", | ||
"visualstudioexptteam.vscodeintellicode", | ||
"ymotongpoo.licenser", | ||
"charliermarsh.ruff", | ||
"ms-python.mypy-type-checker" | ||
] | ||
} | ||
}, | ||
// Use 'forwardPorts' to make a list of ports inside the container available locally. | ||
// "forwardPorts": [5000, 5432], | ||
// Use 'postCreateCommand' to run commands after the container is created. | ||
"postCreateCommand": "dev_install", | ||
// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. | ||
"remoteUser": "vscode", | ||
"containerEnv": { | ||
// for testcontainers to connect to the docker host: | ||
"TC_HOST": "host.docker.internal", | ||
"DOCKER_HOST": "unix:///var/run/docker.sock" | ||
}, | ||
"features": { | ||
// details can be found here: https://github.com/devcontainers/features/tree/main/src/docker-outside-of-docker | ||
"ghcr.io/devcontainers/features/docker-outside-of-docker:1": {} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
version: '3' | ||
|
||
services: | ||
app: | ||
build: | ||
context: . | ||
dockerfile: ./Dockerfile | ||
args: | ||
# [Choice] Python version: 3, 3.8, 3.7, 3.6 | ||
VARIANT: 3.9 | ||
# [Choice] Install Node.js | ||
INSTALL_NODE: "true" | ||
NODE_VERSION: "lts/*" | ||
# Please adapt to package name: | ||
PACKAGE_NAME: "my_microservice" | ||
# On Linux, you may need to update USER_UID and USER_GID below if not your local UID is not 1000. | ||
USER_UID: 1000 | ||
USER_GID: 1000 | ||
|
||
init: true | ||
privileged: true | ||
|
||
volumes: | ||
- ..:/workspace:cached | ||
|
||
# Overrides default command so things don't shut down after the process ends. | ||
command: sleep infinity | ||
|
||
# Uncomment the next line to use a non-root user for all processes. | ||
user: vscode | ||
|
||
# define environment variables | ||
environment: | ||
# Please adapt to package name: | ||
MY_MICROSERVICE_CONFIG_YAML: /workspace/.devcontainer/.dev_config.yaml | ||
# Used by db migration: | ||
DB_URL: postgresql://postgres:postgres@postgresql/postgres | ||
# Use "forwardPorts" in **devcontainer.json** to forward an app port locally. | ||
# (Adding the "ports" property to this file will not forward from a Codespace.) | ||
|
||
|
||
# Please remove service dependencies that are not needed: | ||
mongodb: | ||
image: mongo:latest | ||
restart: unless-stopped | ||
volumes: | ||
- mongo_fs:/data/db | ||
|
||
localstack: | ||
image: localstack/localstack | ||
environment: | ||
SERVICES: s3 | ||
DEFAULT_REGION: eu-west-1 | ||
AWS_DEFAULT_REGION: eu-west-1 | ||
# accessible at localhost | ||
HOSTNAME_EXTERNAL: localhost | ||
USE_SSL: "false" | ||
DATA_DIR: /var/lib/localstack/data | ||
DEBUG: 1 | ||
volumes: | ||
- type: volume | ||
source: s3_fs | ||
target: /var/lib/localstack | ||
volume: | ||
nocopy: true | ||
# useful ports: 4566 - AWS API | ||
|
||
volumes: | ||
s3_fs: {} | ||
mongo_fs: {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
Copyright 2021 - 2023 Universität Tübingen, DKFZ, EMBL, and Universität zu Köln | ||
for the German Human Genome-Phenome Archive (GHGA) | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# CRLF line endings cause problems in Docker, so we force git | ||
# to check in and out using only LF line endings. | ||
|
||
*.cfg text eol=lf | ||
*.ini text eol=lf | ||
*.json text eol=lf | ||
*.md text eol=lf | ||
*.py text eol=lf | ||
*.txt text eol=lf | ||
*.yaml text eol=lf | ||
*.yml text eol=lf | ||
|
||
.editorconfig text eol=lf | ||
.flake8 text eol=lf | ||
.pylintrc text eol=lf | ||
|
||
.git* text eol=lf | ||
*_files text eol=lf | ||
*_files_ignore text eol=lf | ||
|
||
**/dev_* text eol=lf | ||
**/Dockerfile text eol=lf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
name: Check if the config schema and the example are up to date. | ||
|
||
on: push | ||
|
||
jobs: | ||
static-code-analysis: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- id: common | ||
uses: ghga-de/gh-action-common@v4 | ||
|
||
- name: Check config docs | ||
run: | | ||
export ${{ steps.common.outputs.CONFIG_YAML_ENV_VAR_NAME }}="${{ steps.common.outputs.CONFIG_YAML }}" | ||
./scripts/update_config_docs.py --check |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# This file is only needed, if your repository uses FastAPI | ||
name: Check if openapi.yaml is up to date | ||
|
||
on: push | ||
|
||
jobs: | ||
static-code-analysis: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- id: common | ||
uses: ghga-de/gh-action-common@v4 | ||
|
||
- name: Check if openapi.yaml is up to date | ||
run: | | ||
export ${{ steps.common.outputs.CONFIG_YAML_ENV_VAR_NAME }}="${{ steps.common.outputs.CONFIG_YAML }}" | ||
./scripts/update_openapi_docs.py --check |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
name: Check if the config schema and the example are up to date. | ||
|
||
on: push | ||
|
||
jobs: | ||
static-code-analysis: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- id: common | ||
uses: ghga-de/gh-action-common@v4 | ||
|
||
- name: Check pyproject.toml | ||
run: | | ||
./scripts/update_pyproject.py --check |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
name: Check if the readme is up to date. | ||
|
||
on: push | ||
|
||
jobs: | ||
static-code-analysis: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- id: common | ||
uses: ghga-de/gh-action-common@v4 | ||
|
||
- name: Check readme | ||
run: | | ||
./scripts/update_readme.py --check |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
name: Check template files | ||
|
||
on: push | ||
|
||
jobs: | ||
check-template-files: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python 3.9 | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: 3.9 | ||
- name: Check template files | ||
run: | | ||
if [ "${{ github.event.repository.name }}" == "microservice-repository-template" ] | ||
then | ||
echo "Skipping this test as operating on the template repo." | ||
else | ||
./scripts/update_template_files.py --check | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
name: CI on release | ||
|
||
on: | ||
release: | ||
types: [published] | ||
|
||
jobs: | ||
push_to_docker_hub: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: ghga-de/gh-action-ci@v1 | ||
with: | ||
tag: ${{ github.event.release.tag_name }} | ||
dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
dockerhub_token: ${{ secrets.DOCKERHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: Build on PR or dispatch | ||
|
||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
types: | ||
- opened | ||
- synchronize | ||
- reopened | ||
- labeled | ||
|
||
jobs: | ||
fetch-tag: | ||
runs-on: ubuntu-latest | ||
if: github.event_name == 'workflow_dispatch' || ( github.event.action != 'labeled' && contains(github.event.pull_request.labels.*.name, 'build') ) || ( github.event.action == 'labeled' && github.event.label.name == 'build' ) | ||
steps: | ||
- id: fetch-tag | ||
uses: ghga-de/gh-action-fetch-tag@v1 | ||
outputs: | ||
latest_tag: ${{ steps.fetch-tag.outputs.latest_tag }} | ||
|
||
push_to_docker_hub: | ||
needs: fetch-tag | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: ghga-de/gh-action-ci@v1 | ||
with: | ||
tag: ${{ needs.fetch-tag.outputs.latest_tag }}-${{ github.sha }} | ||
dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
dockerhub_token: ${{ secrets.DOCKERHUB_TOKEN }} |
Oops, something went wrong.