Skip to content

Implement Docker, docker-compose and CI/CD (with Kubernetes)#1

Merged
jb3 merged 37 commits into
mainfrom
docker-ci-deployment
Nov 26, 2020
Merged

Implement Docker, docker-compose and CI/CD (with Kubernetes)#1
jb3 merged 37 commits into
mainfrom
docker-ci-deployment

Conversation

@ks129
Copy link
Copy Markdown
Contributor

@ks129 ks129 commented Nov 22, 2020

Docker

Created Dockerfile, .dockerignore and docker-compose.yml files to Docker image building and local development. This uses now uvicorn in development environment and gunicorn with uvicorn worker in production environment, as using plain uvicorn is not suggested in production. docker-compose also run MongoDB instance and pass database information to backend container.

CI/CD, Kubernetes

Created following CI/CD jobs for GH Actions:

  • Linting: Runs flake8 and add errors as annotations.
  • Build & Push: Builds Docker container and push it to GHCR registry. Only run when Linting success and branch is main.
  • Deployment: Deploys application to Kubernetes. Only run when Build & Push success and branch is main.

Required new secrets:

  • GHCR_USER
  • GHCR_TOKEN
  • KUBECONFIG

Other changes

  • Pushed Python version from 3.8 -> 3.9
  • For CORS allowed origins, use ALLOWED_URL variable that defaults to current hard-coded value.

@ks129 ks129 added the area: CI label Nov 22, 2020
@ks129 ks129 requested a review from jb3 November 22, 2020 08:31
@ghost
Copy link
Copy Markdown

ghost commented Nov 22, 2020

Thank you for contributing to Python Discord!

Please check out the following documents:

@ghost ghost added the needs 1 approval label Nov 22, 2020
@ghost ghost added the needs 1 approval label Nov 24, 2020
ks129 and others added 2 commits November 24, 2020 06:38
Co-authored-by: Sebastiaan Zeeff <33516116+SebastiaanZ@users.noreply.github.com>
@ks129 ks129 requested review from SebastiaanZ and jb3 November 24, 2020 04:41
jb3
jb3 previously approved these changes Nov 24, 2020
@ghost ghost removed the needs 1 approval label Nov 24, 2020
Comment thread .github/flake8-matchers.json Outdated
Comment on lines +1 to +32
{
"problemMatcher": [
{
"owner": "flake8-error",
"severity": "error",
"pattern": [
{
"regexp": "^([^:]*):(\\d+):(\\d+): ([EF]\\d\\d\\d) (.*)$",
"file": 1,
"line": 2,
"column": 3,
"code": 4,
"message": 5
}
]
},
{
"owner": "flake8-warning",
"severity": "warning",
"pattern": [
{
"regexp": "^([^:]*):(\\d+):(\\d+): ([W]\\d\\d\\d) (.*)$",
"file": 1,
"line": 2,
"column": 3,
"code": 4,
"message": 5
}
]
}
]
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How will these matchers react to the error codes of flake8-annotations, ANN001? They don't match either pattern, as your pattern for errors only matched [EF] in the error code section and your warning one only [W]. A slightly less sophisticated method would be to have flake8 output its error messages in the proper format for annotations directly.

This means you wouldn't have to worry about the CI when error codes change in the future (e.g., we add more plugins).

Comment thread tox.ini Outdated
SebastiaanZ
SebastiaanZ previously approved these changes Nov 26, 2020
@ghost ghost removed the needs 1 approval label Nov 26, 2020
@ks129 ks129 requested a review from jb3 November 26, 2020 15:41
Copy link
Copy Markdown
Member

@jb3 jb3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to fetch the environment for the container

Comment thread deployment.yaml
Co-authored-by: Joe Banks <joseph@josephbanks.me>
@ghost ghost removed the needs 1 approval label Nov 26, 2020
@jb3 jb3 merged commit 182da79 into main Nov 26, 2020
@jb3 jb3 deleted the docker-ci-deployment branch November 26, 2020 18:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants