Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use DigitalOcean for hosting #1133

Open
wants to merge 16 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -85,19 +85,19 @@ docs:
docker-compose run backend bash -c 'cd ../docs&&sphinx-build -b html -d _build/doctrees . _build/html'

build_balancer:
docker build -t docker-registry.siecobywatelska.pl/small_eod/balancer:${TAG} balancer/
docker build -t registry.digitalocean.com/ad-masterthesis/small-eod/balancer:${TAG} balancer/

build_frontend:
docker build --target prod -t docker-registry.siecobywatelska.pl/small_eod/frontend:${TAG} frontend-project/
docker build --target prod -t registry.digitalocean.com/ad-masterthesis/small-eod/frontend:${TAG} frontend-project/

build_backend:
docker build --target prod -t docker-registry.siecobywatelska.pl/small_eod/backend:${TAG} backend-project/
docker build --target prod -t registry.digitalocean.com/ad-masterthesis/small-eod/backend:${TAG} backend-project/

push_balancer:
docker push docker-registry.siecobywatelska.pl/small_eod/balancer:${TAG}
docker push registry.digitalocean.com/ad-masterthesis/small-eod/balancer:${TAG}

push_frontend:
docker push docker-registry.siecobywatelska.pl/small_eod/frontend:${TAG}
docker push registry.digitalocean.com/ad-masterthesis/small-eod/frontend:${TAG}

push_backend:
docker push docker-registry.siecobywatelska.pl/small_eod/backend:${TAG}
docker push registry.digitalocean.com/ad-masterthesis/small-eod/backend:${TAG}
4 changes: 2 additions & 2 deletions backend-project/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ FROM prod_settings AS prod
RUN pip install --no-cache-dir -r $REQS_FILE
COPY . /code/
# timeout increased due slow loading of pyparsing
CMD ["bash", "-c", "python manage.py collectstatic --no-input && python manage.py migrate && gunicorn -w 3 -b 0.0.0.0:8000 --timeout 60 config.wsgi"]
CMD ["bash", "-c", "python manage.py collectstatic --no-input && python manage.py migrate --no-input && gunicorn --worker-tmp-dir /dev/shm/ --capture-output -b 0.0.0.0:8000 config.wsgi"]

# DEVELOPMENT BUILD
FROM dev_settings AS dev
# Add git required by coveralls
RUN pip install --no-cache-dir -r $REQS_FILE
COPY . /code/
CMD ["bash", "-c", "python manage.py collectstatic --no-input && python manage.py migrate && python manage.py runserver 0.0.0.0:8000"]
CMD ["bash", "-c", "python manage.py collectstatic --no-input && python manage.py migrate --no-input && python manage.py runserver 0.0.0.0:8000"]
2 changes: 1 addition & 1 deletion backend-project/config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@

DATABASES = {
"default": env.db(),
"migration": env.db("MIGRATION_DATABASE_URL"),
"migration": env.db("MIGRATION_DATABASE_URL", default="sqlite://:memory:"),
}

# Password validation
Expand Down
4 changes: 3 additions & 1 deletion backend-project/small_eod/tags/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ def __init__(self, *args, **kwargs):

def to_representation(self, data):
return [
self.child.to_representation(item) if item is not None else None
self.child.to_representation(item)
if item is not None and hasattr(item, "all")
else None
for item in data.all()
]
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ services:
frontend:
build:
context: ./frontend-project
target: dev
environment:
COMMIT_SHA: '${COMMIT_SHA:-unknown_sha}'
COMMIT_BRANCH: '${COMMIT_BRANCH:-unknown_branch}'
Expand Down
8 changes: 4 additions & 4 deletions frontend-project/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ FROM node:16.9.1-slim@sha256:af6f241029c4d63107c6ccbbd030c44d331786d724bd9c2e615
RUN apt update && apt install -y g++ git make python3
WORKDIR /code

# DEVELOPMENT BUILD
FROM env
CMD ["bash", "-c", "yarn && yarn start"]

# PRODUCTION BUILD
FROM env AS builder
COPY ./ /code
Expand All @@ -13,7 +17,3 @@ COPY ./nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=builder /code/dist /usr/share/nginx/html
EXPOSE 8000
CMD ["nginx", "-g", "daemon off;"]

# DEVELOPMENT BUILD
FROM env
CMD ["bash", "-c", "yarn && yarn start"]
4 changes: 2 additions & 2 deletions frontend-project/vercel.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"version": 2,
"routes": [
{ "src": "/api/(?<path>.*)", "dest": "https://dev.small-eod.siecobywatelska.pl/api/$path" },
{ "src": "/api/(?<path>.*)", "dest": "https://small-eod-dev-4nvf3.ondigitalocean.app/api/$path" },
{
"src": "/static/(?<path>.*)",
"dest": "https://dev.small-eod.siecobywatelska.pl/static/$path"
"dest": "https://small-eod-dev-4nvf3.ondigitalocean.app/static/$path"
},
{ "handle": "filesystem" },
{ "src": "/.*", "dest": "/index.html" }
Expand Down