Skip to content

Commit

Permalink
install postgres
Browse files Browse the repository at this point in the history
  • Loading branch information
felix1110xx committed Jul 15, 2024
1 parent f25ce18 commit 0b82cf2
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 2 deletions.
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion app/app/calc.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ def add(x,y):
return x + y

def subtract(x,y):
return x - y
return x - y
3 changes: 2 additions & 1 deletion app/app/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ def test_add_numbers(self):

def test_subtract_numbers(self):
res = calc.subtract(10, 5)
self.assertEqual(res, 5)
self.assertEqual(res, 5)

21 changes: 21 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,24 @@ services:
- ./app:/app
command: >
sh -c "python manage.py runserver 0.0.0.0:8000"
environment:
- DB_HOST=db
- DB_NAME=devdb
- DB_USER=devuser
- DB_PASSWORD=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:

1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
Django>=3.2.4,<3.3
djangorestframework>=3.12.4,<3.13
psycopg2>=2.8.6,<2.9

0 comments on commit 0b82cf2

Please sign in to comment.