From 6c0fbe6efc82d76b2b4edb2e2e5bae8cd447def2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lauri=20V=C3=B5sandi?= Date: Fri, 22 Apr 2022 01:15:48 +0300 Subject: [PATCH] Initial commit --- .drone.yml | 16 ++++++++++++++++ .flake8 | 6 ++++++ .gitignore | 1 + .gitlint | 9 +++++++++ .pre-commit-config.yaml | 16 ++++++++++++++++ Dockerfile | 7 +++++++ README.md | 29 +++++++++++++++++++++++++++++ docker-compose.yml | 27 +++++++++++++++++++++++++++ main.py | 2 ++ 9 files changed, 113 insertions(+) create mode 100644 .drone.yml create mode 100644 .flake8 create mode 100644 .gitignore create mode 100644 .gitlint create mode 100644 .pre-commit-config.yaml create mode 100644 Dockerfile create mode 100644 README.md create mode 100644 docker-compose.yml create mode 100755 main.py diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..7e9134b --- /dev/null +++ b/.drone.yml @@ -0,0 +1,16 @@ +--- +kind: pipeline +type: kubernetes +name: default + +steps: +- name: docker + image: plugins/docker + settings: + repo: harbor.k-space.ee/${DRONE_REPO} + registry: harbor.k-space.ee + mtu: 1300 + username: + from_secret: docker_username + password: + from_secret: docker_password diff --git a/.flake8 b/.flake8 new file mode 100644 index 0000000..ff6c948 --- /dev/null +++ b/.flake8 @@ -0,0 +1,6 @@ +[flake8] +inline-quotes = " +multiline-quotes = """ +indent-size = 4 +max-line-length = 160 +ignore = Q003 E128 E704 E731 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1a44989 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.save diff --git a/.gitlint b/.gitlint new file mode 100644 index 0000000..9045422 --- /dev/null +++ b/.gitlint @@ -0,0 +1,9 @@ +[general] +ignore=body-is-missing,T3 +ignore-stdin=true + +[title-match-regex] +regex=[A-Z] + +[author-valid-email] +regex=[^@]+@k-space.ee diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..23d9eb4 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,16 @@ +repos: +- repo: https://github.com/PyCQA/flake8 + rev: 3.9.2 + hooks: + - id: flake8 + additional_dependencies: [flake8-typing-imports==1.10.0,flake8-quotes==3.2.0] + +- repo: https://github.com/jorisroovers/gitlint + rev: v0.15.1 + hooks: + - id: gitlint + +- repo: https://github.com/Lucas-C/pre-commit-hooks-nodejs + rev: v1.1.1 + hooks: + - id: dockerfile_lint diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..fb28c07 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,7 @@ +FROM python:alpine +LABEL name="k-space/microscript-skeleton" \ + version="rc" \ + maintainer="Lauri Võsandi " +RUN pip install pymongo +ADD main.py /main.py +CMD /main.py diff --git a/README.md b/README.md new file mode 100644 index 0000000..1f05b97 --- /dev/null +++ b/README.md @@ -0,0 +1,29 @@ +# Introduction + +This repository is a skeleton for a microscript container image -- that +is container that get's started either by Kubernetes Job or CronJob and +that does not run forever. + +In this particular example MongoDB is included in the setup. + +# How to use this repository + +* Fork with suitable name under `k-space` organization +* Adjust maintainer name and e-mail in `Dockerfile +* Add/remove dependencies as necessary in `Dockerfile` +* Make sure `docker-compose.yml` brings up sensible development environment + +# Prerequisites + +* Docker runtime is installed +* Your user is user of group `docker` +* Docker compose is installed +* Pre-commit framework is installed, if necessary `apt-get install pre-commit` + +# Development environment + +``` +docker-compose up --build +``` + +To access MongoExpress open up http://localhost:8081/ diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..79939a4 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,27 @@ +version: '3.7' +services: + main: + build: + context: . + + mongo: + logging: + driver: none + image: mongo + restart: always + environment: + MONGO_INITDB_ROOT_USERNAME: root + MONGO_INITDB_ROOT_PASSWORD: example + + mongo-express: + logging: + driver: none + image: mongo-express + restart: always + ports: + - 8081:8081 + environment: + ME_CONFIG_MONGODB_ADMINUSERNAME: root + ME_CONFIG_MONGODB_ADMINPASSWORD: example + ME_CONFIG_MONGODB_URL: mongodb://root:example@mongo:27017/ + diff --git a/main.py b/main.py new file mode 100755 index 0000000..2219d93 --- /dev/null +++ b/main.py @@ -0,0 +1,2 @@ +#!/usr/bin/env python +print("Hello world")