Skip to content

Commit 6f0ee90

Browse files
committed
Implement initial project structure and setup
1 parent f2b049a commit 6f0ee90

File tree

19 files changed

+3210
-0
lines changed

19 files changed

+3210
-0
lines changed

.github/workflows/docker-build.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: Build and Push Docker Image
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
tags: [ 'v*' ]
7+
pull_request:
8+
branches: [ main ]
9+
10+
env:
11+
REGISTRY: docker.io
12+
IMAGE_NAME: admin9705/budget101
13+
14+
jobs:
15+
build:
16+
runs-on: ubuntu-latest
17+
permissions:
18+
contents: read
19+
packages: write
20+
21+
steps:
22+
- name: Checkout repository
23+
uses: actions/checkout@v4
24+
25+
- name: Set up Docker Buildx
26+
uses: docker/setup-buildx-action@v3
27+
28+
- name: Log in to Docker Hub
29+
if: github.event_name != 'pull_request'
30+
uses: docker/login-action@v3
31+
with:
32+
registry: ${{ env.REGISTRY }}
33+
username: ${{ secrets.DOCKERHUB_USERNAME }}
34+
password: ${{ secrets.DOCKERHUB_TOKEN }}
35+
36+
- name: Extract metadata
37+
id: meta
38+
uses: docker/metadata-action@v5
39+
with:
40+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
41+
tags: |
42+
type=ref,event=branch
43+
type=ref,event=pr
44+
type=semver,pattern={{version}}
45+
type=semver,pattern={{major}}.{{minor}}
46+
type=semver,pattern={{major}}
47+
type=raw,value=latest,enable={{is_default_branch}}
48+
49+
- name: Build and push Docker image
50+
uses: docker/build-push-action@v5
51+
with:
52+
context: .
53+
file: ./Dockerfile
54+
platforms: linux/amd64,linux/arm64
55+
push: ${{ github.event_name != 'pull_request' }}
56+
tags: ${{ steps.meta.outputs.tags }}
57+
labels: ${{ steps.meta.outputs.labels }}
58+
cache-from: type=gha
59+
cache-to: type=gha,mode=max
60+
61+
- name: Update Docker Hub description
62+
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
63+
uses: peter-evans/dockerhub-description@v3
64+
with:
65+
username: ${{ secrets.DOCKERHUB_USERNAME }}
66+
password: ${{ secrets.DOCKERHUB_TOKEN }}
67+
repository: ${{ env.IMAGE_NAME }}
68+
readme-filepath: ./README.md

.gitignore

Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
wheels/
23+
pip-wheel-metadata/
24+
share/python-wheels/
25+
*.egg-info/
26+
.installed.cfg
27+
*.egg
28+
MANIFEST
29+
30+
# PyInstaller
31+
# Usually these files are written by a python script from a template
32+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
33+
*.manifest
34+
*.spec
35+
36+
# Installer logs
37+
pip-log.txt
38+
pip-delete-this-directory.txt
39+
40+
# Unit test / coverage reports
41+
htmlcov/
42+
.tox/
43+
.nox/
44+
.coverage
45+
.coverage.*
46+
.cache
47+
nosetests.xml
48+
coverage.xml
49+
*.cover
50+
*.py,cover
51+
.hypothesis/
52+
.pytest_cache/
53+
54+
# Virtual environments
55+
venv/
56+
env/
57+
ENV/
58+
.venv/
59+
.env/
60+
61+
# Flask instance folder
62+
instance/
63+
64+
# Flask session and config
65+
.session
66+
.env
67+
68+
# Jupyter Notebook
69+
.ipynb_checkpoints
70+
71+
# IPython
72+
profile_default/
73+
ipython_config.py
74+
75+
# pyenv
76+
.python-version
77+
78+
# pipenv
79+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
80+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
81+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
82+
# install all needed dependencies.
83+
Pipfile.lock
84+
85+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
86+
__pypackages__/
87+
88+
# Celery stuff
89+
celerybeat-schedule
90+
celerybeat.pid
91+
92+
# SageMath parsed files
93+
*.sage.py
94+
95+
# Environments
96+
.env
97+
.venv
98+
env/
99+
venv/
100+
ENV/
101+
env.bak/
102+
venv.bak/
103+
104+
# Spyder project settings
105+
.spyderproject
106+
.spyproject
107+
108+
# Rope project settings
109+
.ropeproject
110+
111+
# mkdocs documentation
112+
/site
113+
114+
# mypy
115+
.mypy_cache/
116+
.dmypy.json
117+
dmypy.json
118+
119+
# Pyre type checker
120+
.pyre/
121+
122+
# Budget101 specific
123+
config/config.yml
124+
config/*.db
125+
config/*.log
126+
config/backups/
127+
128+
# Docker
129+
.dockerignore
130+
131+
# IDE
132+
.vscode/
133+
.idea/
134+
*.swp
135+
*.swo
136+
*~
137+
138+
# OS
139+
.DS_Store
140+
.DS_Store?
141+
._*
142+
.Spotlight-V100
143+
.Trashes
144+
ehthumbs.db
145+
Thumbs.db
146+
147+
# Logs
148+
*.log
149+
logs/
150+
151+
# Database
152+
*.db
153+
*.sqlite
154+
*.sqlite3
155+
156+
# Temporary files
157+
tmp/
158+
temp/
159+
*.tmp
160+
161+
# Node modules (if any)
162+
node_modules/
163+
164+
# Backup files
165+
*.bak
166+
*.backup

Dockerfile

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
FROM python:3.11-slim
2+
3+
# Set working directory
4+
WORKDIR /app
5+
6+
# Install system dependencies
7+
RUN apt-get update && apt-get install -y \
8+
gcc \
9+
&& rm -rf /var/lib/apt/lists/*
10+
11+
# Copy requirements first for better caching
12+
COPY requirements.txt .
13+
14+
# Install Python dependencies
15+
RUN pip install --no-cache-dir --upgrade pip && \
16+
pip install --no-cache-dir -r requirements.txt
17+
18+
# Copy application code
19+
COPY . .
20+
21+
# Create config directory
22+
RUN mkdir -p /config
23+
24+
# Create non-root user for security
25+
RUN groupadd -r appuser && useradd -r -g appuser appuser
26+
RUN chown -R appuser:appuser /app /config
27+
28+
# Expose port 9715
29+
EXPOSE 9715
30+
31+
# Switch to non-root user
32+
USER appuser
33+
34+
# Health check
35+
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
36+
CMD python -c "import requests; requests.get('http://localhost:9715/health', timeout=5)" || exit 1
37+
38+
# Run the application
39+
CMD ["gunicorn", "--bind", "0.0.0.0:9715", "--workers", "2", "--timeout", "30", "app:app"]

0 commit comments

Comments
 (0)