commit 46faba149f66f5aa3cf46f01d62e072f0cc1ef7a Author: moustapha niang Date: Wed Mar 12 14:44:52 2025 +0000 Initial commit diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..8d3a867 --- /dev/null +++ b/.drone.yml @@ -0,0 +1,26 @@ +--- +kind: pipeline +type: kubernetes +name: build + +platform: + os: linux + arch: amd64 + +steps: +- name: build_docker_image + image: plugins/docker:20.14 + settings: + username: + from_secret: registry_username + password: + from_secret: registry_token + registry: git.lab.adho.app + repo: git.lab.adho.app/{{ username }}/exempleci + dockerfile: Dockerfile + mtu: 1440 + +trigger: + event: + - push + - pull_request \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5d381cc --- /dev/null +++ b/.gitignore @@ -0,0 +1,162 @@ +# ---> Python +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +cover/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +.pybuilder/ +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# poetry +# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. +# This is especially recommended for binary packages to ensure reproducibility, and is more +# commonly ignored for libraries. +# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control +#poetry.lock + +# pdm +# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. +#pdm.lock +# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it +# in version control. +# https://pdm.fming.dev/#use-with-ide +.pdm.toml + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ + +# PyCharm +# JetBrains specific template is maintained in a separate JetBrains.gitignore that can +# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore +# and can be added to the global gitignore or merged into this file. For a more nuclear +# option (not recommended) you can uncomment the following to ignore the entire idea folder. +#.idea/ + diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..9a409be --- /dev/null +++ b/Dockerfile @@ -0,0 +1,20 @@ +# start by pulling the python image +FROM python:3.8-alpine + +# copy the requirements file into the image +COPY ./src/requirements.txt /app/requirements.txt + +# switch working directory +WORKDIR /app + +# install the dependencies and packages in the requirements file +RUN pip install -r requirements.txt + +# copy every content from the local file to the image +COPY ./src/view.py /app/view.py +COPY ./src/templates /app/templates + +# configure the container to run in an executed manner +ENTRYPOINT [ "python" ] + +CMD ["view.py" ] diff --git a/README.md b/README.md new file mode 100644 index 0000000..087bf3a --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# exemple_ci + diff --git a/manifests/01_deployment.yml b/manifests/01_deployment.yml new file mode 100644 index 0000000..3b75913 --- /dev/null +++ b/manifests/01_deployment.yml @@ -0,0 +1,35 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: exempleci-deployment + labels: + app: exempleci +spec: + selector: + matchLabels: + app: exempleci + replicas: 1 + template: + metadata: + labels: + app: exempleci + spec: + containers: + - name: flask + image: git.lab.adho.app/{{ username }}/exempleci:latest + livenessProbe: + httpGet: + path: / + port: 5000 + initialDelaySeconds: 10 + periodSeconds: 5 + startupProbe: + httpGet: + path: / + port: 5000 + failureThreshold: 30 + periodSeconds: 20 + ports: + - containerPort: 5000 + imagePullSecrets: + - name: registry-lab-secret \ No newline at end of file diff --git a/manifests/02_service.yml b/manifests/02_service.yml new file mode 100644 index 0000000..6c5ea90 --- /dev/null +++ b/manifests/02_service.yml @@ -0,0 +1,13 @@ +kind: Service +apiVersion: v1 +metadata: + name: exempleci + labels: + app: exempleci +spec: + type: ClusterIP + selector: + app: exempleci + ports: + - port: 5000 + targetPort: 5000 \ No newline at end of file diff --git a/manifests/03_ingress.yml b/manifests/03_ingress.yml new file mode 100644 index 0000000..07d777a --- /dev/null +++ b/manifests/03_ingress.yml @@ -0,0 +1,25 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: exempleci-ingress + annotations: + cert-manager.io/cluster-issuer: letsencrypt-prod + labels: + app: exempleci +spec: + ingressClassName: nginx + tls: + - hosts: + - exempleci.{{TRIGRAMME}}.lab.adho.app + secretName: exempleci-tls + rules: + - host: exempleci.{{TRIGRAMME}}.lab.adho.app + http: + paths: + - pathType: Prefix + path: "/" + backend: + service: + name: exempleci + port: + number: 5000 \ No newline at end of file diff --git a/src/requirements.txt b/src/requirements.txt new file mode 100644 index 0000000..8ddfcf2 --- /dev/null +++ b/src/requirements.txt @@ -0,0 +1,8 @@ +click==8.0.3 +colorama==0.4.4 +Flask==2.0.2 +itsdangerous==2.0.1 +Jinja2==3.0.3 +MarkupSafe==2.0.1 +Werkzeug==2.0.2 +gunicorn==20.1.0 diff --git a/src/templates/index.html b/src/templates/index.html new file mode 100644 index 0000000..2bd6745 --- /dev/null +++ b/src/templates/index.html @@ -0,0 +1,11 @@ + + + + + + Ma super app + + +

Ma super application++

+ + diff --git a/src/view.py b/src/view.py new file mode 100644 index 0000000..2153d5c --- /dev/null +++ b/src/view.py @@ -0,0 +1,14 @@ +from flask import Flask, render_template +import os + +app = Flask(__name__) + + +@app.route('/') +def home(): + return render_template('index.html') + + +if __name__ == "__main__": + port = int(os.environ.get('PORT', 5000)) + app.run(debug=True, host='0.0.0.0', port=port)