Skip to content

Commit e1cb69d

Browse files
authored
[NEW] Initial commit (#1)
1 parent b006ffe commit e1cb69d

18 files changed

+672
-2
lines changed

.env.template

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
MONGO_URI="mongodb://user:password@mongodb.atesmaps.org:27017?tls=true&authMechanism=DEFAULT"
2+
MONGO_DATABASE=my-database
3+
4+
SPACES_REGION=ams3
5+
SPACES_ENDPOINT=https://my-spaces-id.ams3.digitaloceanspaces.com
6+
SPACES_ACCESS_KEY=my-access-key
7+
SPACES_SECRET_ACCESS_KEY=my-secret-access-key
8+
SPACES_BUCKET_ID=my-spaces-id

.flake8

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[flake8]
2+
exclude = __init__.py
3+
ignore = E203, E211, E266, E501, E999, F401, F403, F821, W503
4+
max-line-length = 88

.github/dependabot.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: github-actions
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"
7+
commit-message:
8+
prefix: "⬆Github Actions"
9+
include: "scope"
10+
- package-ecosystem: "pip"
11+
directory: "/"
12+
schedule:
13+
interval: "weekly"
14+
commit-message:
15+
prefix: "⬆PipEnv"
16+
- package-ecosystem: "docker"
17+
directory: "/"
18+
schedule:
19+
interval: "weekly"
20+
commit-message:
21+
prefix: "⬆Docker"

.github/workflows/deploy.yaml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: Release & Deploy
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
workflow_dispatch:
8+
9+
concurrency:
10+
group: deploy
11+
cancel-in-progress: true
12+
13+
permissions:
14+
contents: write
15+
id-token: write
16+
17+
jobs:
18+
build-deploy:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Git Checkout
22+
uses: actions/checkout@v4
23+
with:
24+
fetch-depth: 0
25+
- name: Get latest tag
26+
id: latest_tag
27+
uses: WyriHaximus/github-action-get-previous-tag@v1
28+
- name: Get next minor version
29+
id: semvers
30+
uses: WyriHaximus/github-action-next-semvers@v1
31+
with:
32+
version: ${{ steps.latest_tag.outputs.tag }}
33+
- name: Build
34+
uses: docker/build-push-action@v5
35+
with:
36+
context: .
37+
file: Dockerfile
38+
push: false
39+
tags: |
40+
atesmaps-mongo-backup:latest
41+
- name: Export Docker image
42+
run: |
43+
docker save atesmaps-mongo-backup:latest | gzip > ./atesmaps-mongo-backup.tar.gz
44+
- name: Push Docker image artifact
45+
uses: appleboy/scp-action@v0.1.7
46+
with:
47+
host: ${{ secrets.SSH_DEV_HOST }}
48+
username: ${{ secrets.SSH_USER }}
49+
key: ${{ secrets.SSH_KEY }}
50+
port: ${{ secrets.SSH_PORT }}
51+
source: ./atesmaps-mongo-backup.tar.gz
52+
target: /tmp
53+
- name: Load Docker Artifact
54+
uses: appleboy/ssh-action@v1.0.2
55+
with:
56+
host: ${{ secrets.SSH_PROD_HOST }}
57+
username: ${{ secrets.SSH_USER }}
58+
key: ${{ secrets.SSH_KEY }}
59+
port: ${{ secrets.SSH_PORT }}
60+
script: |
61+
gunzip -c /tmp/atesmaps-mongo-backup.tar.gz | docker load
62+
docker image prune -f
63+
- name: Create Release
64+
id: create_release
65+
uses: actions/create-release@v1
66+
env:
67+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
68+
with:
69+
tag_name: ${{ steps.semvers.outputs.v_patch }}
70+
release_name: ${{ steps.semvers.outputs.v_patch }}
71+
body: |
72+
New Atesmaps DigitalOcean Tools build released!
73+
draft: false
74+
prerelease: false

.isort.cfg

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[settings]
2+
line_length = 88
3+
multi_line_output = 3
4+
include_trailing_comma = True

.pre-commit-config.yaml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# See https://pre-commit.com for more information
2+
# See https://pre-commit.com/hooks.html for more hooks
3+
repos:
4+
- repo: https://github.com/pre-commit/pre-commit-hooks
5+
rev: v4.5.0
6+
hooks:
7+
- id: check-added-large-files
8+
- id: check-yaml
9+
args:
10+
- --unsafe
11+
- id: end-of-file-fixer
12+
- id: trailing-whitespace
13+
- repo: https://github.com/myint/autoflake
14+
rev: v2.2.1
15+
hooks:
16+
- id: autoflake
17+
args:
18+
- --recursive
19+
- --in-place
20+
- --remove-all-unused-imports
21+
- --remove-unused-variables
22+
- --expand-star-imports
23+
- --exclude
24+
- __init__.py
25+
- --remove-duplicate-keys
26+
- repo: https://github.com/pycqa/isort
27+
rev: 5.12.0
28+
hooks:
29+
- id: isort
30+
name: isort (python)
31+
- repo: https://github.com/psf/black
32+
rev: 23.11.0
33+
hooks:
34+
- id: black
35+
ci:
36+
autofix_commit_msg: 🎨 [pre-commit.ci] Auto format from pre-commit.com hooks
37+
autoupdate_commit_msg: ⬆ [pre-commit.ci] pre-commit autoupdate

Dockerfile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
FROM python:3.12
2+
3+
ENV DEBIAN_FRONTEND=noninteractive
4+
ENV PROJECT_DIR=/app
5+
WORKDIR ${PROJECT_DIR}
6+
7+
RUN apt-get update \
8+
&& apt-get dist-upgrade -y \
9+
&& rm -rf /var/lib/apt/lists/*
10+
11+
RUN pip install --upgrade pip && pip install pipenv
12+
13+
COPY Pipfile* ${PROJECT_DIR}/
14+
15+
RUN pipenv install --system --deploy
16+
17+
COPY src ${PROJECT_DIR}/
18+
19+
ENTRYPOINT ["/usr/local/bin/python"]
20+
CMD ["main.py"]

Pipfile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[[source]]
2+
url = "https://pypi.python.org/simple"
3+
verify_ssl = true
4+
name = "pypi"
5+
6+
[requires]
7+
python_version = "3.12"
8+
9+
[packages]
10+
pymongo = "*"
11+
boto3 = "*"
12+
13+
[dev-packages]
14+
black = "*"

0 commit comments

Comments
 (0)