Skip to content

Commit

Permalink
postgres-sql config + dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
rotem123456 committed Jun 30, 2024
1 parent c71def6 commit 4cb9c42
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@
- name: Checkout
uses: actions/checkout@v2
- name: Test
run: docker-compose run --rm app sh -c "python manage.py test"
run: docker-compose run --rm app sh -c "python3 manage.py test"
- name: Lint
run: docker-compose run --rm app sh -c "flake8"
6 changes: 5 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.11-alpine
FROM python:3.9-alpine3.13
LABEL maintainer="londonappdeveloper.com"

ENV PYTHONUNBUFFERED 1
Expand All @@ -12,11 +12,15 @@ EXPOSE 8000
ARG DEV=false
RUN python -m venv /py && \
/py/bin/pip install --upgrade pip && \
apk add --update --no-cache postgresql-client && \
apk add --update --no-cache --virtual .tmp-build-deps \
build-base postgresql-dev musl-dev && \
/py/bin/pip install -r /tmp/requirements.txt && \
if [ $DEV = "true" ]; \
then /py/bin/pip install -r /tmp/requirements.dev.txt ; \
fi && \
rm -rf /tmp && \
apk del .tmp-build-deps && \
adduser \
--disabled-password \
--no-create-home \
Expand Down
7 changes: 7 additions & 0 deletions app/app/calc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
"""
calculator function
"""

def add(x, y):
"""Add x and y and return result"""
return x + y
16 changes: 16 additions & 0 deletions app/app/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
sample tests
"""

from django.test import SimpleTestCase

from app import calc

class CalcTests(SimpleTestCase):
"""Test the calc module"""

def test_add_numners(self):
"""Test adding numbers togethers"""
res = calc.add(5, 6)

self.assertEqual(res, 11)
1 change: 1 addition & 0 deletions app/manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ def main():

if __name__ == '__main__':
main()

22 changes: 21 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,24 @@ services:
volumes:
- ./app:/app
command: >
sh -c "python manage.py runserver 0.0.0.0:8000"
sh -c "python manage.py runserver 0.0.0.0:8000"
environment:
- DB_HOST=db
- DB_NAME=devdb
- DB_USER=devuser
- DB_PASS=changeme
depends_on:
- db

db:
image: postgres:13-alpine
volumes:
- dev-db-data:/var/lib/postgresql/data
environment:
- POSTGRES_DB=devdb
- POSTGRES_USER=devuser
- POSTGRES_PASSWORD=changeme


volumes:
dev-db-data:

0 comments on commit 4cb9c42

Please sign in to comment.