-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
77261ca
commit f94f243
Showing
7 changed files
with
110 additions
and
53 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,32 @@ | ||
FROM python:3.9-alpine3.13 | ||
LABEL maintainer="[email protected]" | ||
|
||
ENV PYTHONUNBUFFERED 1 | ||
|
||
COPY ./requirements.txt /tmp/requirements.txt | ||
COPY ./requirements.dev.txt /tmp/requirements.dev.txt | ||
COPY ./app /app | ||
WORKDIR /app | ||
EXPOSE 8000 | ||
|
||
ARG DEV=false | ||
RUN python -m venv /py && \ | ||
/py/bin/pip install --upgrade pip && \ | ||
/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 && \ | ||
adduser \ | ||
--disabled-password \ | ||
--no-create-home \ | ||
django-user | ||
|
||
ENV PATH="/py/bin:$PATH" | ||
|
||
USER django-user | ||
|
||
FROM python:3.9-alpine3.13 | ||
LABEL maintainer="[email protected]" | ||
|
||
ENV PYTHONUNBUFFERED 1 | ||
|
||
COPY ./requirements.txt /tmp/requirements.txt | ||
COPY ./requirements.dev.txt /tmp/requirements.dev.txt | ||
COPY ./app /app | ||
WORKDIR /app | ||
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 \ | ||
django-user | ||
|
||
ENV PATH="/py/bin:$PATH" | ||
|
||
USER django-user | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
""" | ||
Calculator functions | ||
""" | ||
|
||
|
||
def add(x, y): | ||
""" Add two numbers.""" | ||
return x + y | ||
|
||
|
||
def subtract(x, y): | ||
""" Subtracting x from y """ | ||
return x - y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
""" | ||
Sample tests | ||
""" | ||
from django.test import SimpleTestCase | ||
|
||
from . import calc | ||
|
||
|
||
class CalculatorTests(SimpleTestCase): | ||
""" Test the calc module """ | ||
def test_add_numbers(self): | ||
""" Test adding two numbers """ | ||
res = calc.add(3, 6) | ||
self.assertEqual(res, 9) | ||
|
||
def test_subtract_numbers(self): | ||
""" Testing subtracting two numbers """ | ||
res = calc.subtract(10, 5) | ||
|
||
self.assertEqual(res, 5) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,34 @@ | ||
version: "3.9" | ||
|
||
services: | ||
app: | ||
build: | ||
context: . | ||
args: | ||
- DEV=true | ||
ports: | ||
- "8000:8000" | ||
volumes: | ||
- ./app:/app | ||
command: > | ||
sh -c "python manage.py runserver 0.0.0.0:8000" | ||
version: "3.9" | ||
|
||
services: | ||
app: | ||
build: | ||
context: . | ||
args: | ||
- DEV=true | ||
ports: | ||
- "8000:8000" | ||
volumes: | ||
- ./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_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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
Django>=3.2.4,<3.3 | ||
djangorestframework>=3.12.4,<3.13 | ||
psycopg2>=2.8.6,<2.9 |