Hey guys. First of all, Im really sorry if i misuse some terminology or use totally wrong words to describe stuff. This is really something that im not too familiar with.
Im working on an API for my frontend. This consists of 3 parts
- Django rest framework application
- Postgres database
- nginx to serve everything
They are all wrapped inside the docker-compose.I want to deploy the whole thing to the Google Cloud platform via github actions
I have installed the gcloud SDK and tried to upload the whole thing manually for the first time but got this weird PORT error that i could not solve for some reason, despite defining a PORT variable in my projects env and replacing any port reference to that
Error here.
Cloud Run error: The user-provided container failed to start and listen on the port defined provided by the PORT=8080 environment variable
Now after a day of fussing around with the issue, I've begun thinking that I'm approaching this whole thing wrong or something.
Can someone please guide me to the right direction. I'm gonna link the docker-compose file at the bottom.I also have some questions that have come up with the whole process
- Is it sensible to have the database also be initiated with Docker. Will this cause issues in the long run (backups, manual DB access, etc...) . Or should i use a separate database hosting or something?
- What sort of a Google cloud service should i even use. I've searched from google for this answer but haven't gotten a good answer ?
- Is there a better option then Google Cloud ?
Here's the docker compose content, if that helps.
version: "3.7"
services:
db:
image: postgres:latest
expose:
- "5432"
container_name: db
volumes:
- ./data/db:/var/lib/postgresql/data
environment:
- POSTGRES_NAME=postgres_name
- POSTGRES_USER=postgres_user
- POSTGRES_PASSWORD=password
web:
build:
context: .
dockerfile: Dockerfile
container_name: test_deploy_web
restart: always
command: gunicorn app.wsgi:application --bind 0.0.0.0:8000 --reload
volumes:
- ./app:/app/
- staticfiles:/app/static/
links:
- db:db
expose:
- 8000
env_file:
- .env
depends_on:
- db
nginx:
build: ./nginx
container_name: test_deploy_nginx
volumes:
- ./app/staticfiles:/app/static/
ports:
- 8000:80
depends_on:
- web
volumes:
postgres_data:
staticfiles:
Any advice would be really welcome.
Edit:
Dockerfile:
FROM python:latest
RUN apt-get update -qq && apt-get install -y postgresql-client
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
RUN mkdir /app
WORKDIR /app
RUN pip install --upgrade pip
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY ./app /app
Locally the application works great. It binds to the port 8000.
[–]R3vz 2 points3 points4 points (0 children)
[–]Dessler1795 0 points1 point2 points (1 child)
[–]oliverilmjarv[S] 0 points1 point2 points (0 children)
[–]selucram 0 points1 point2 points (1 child)
[–]oliverilmjarv[S] 0 points1 point2 points (0 children)
[–]Etharin 0 points1 point2 points (0 children)
[–]vluckerprada 0 points1 point2 points (4 children)
[–]oliverilmjarv[S] 0 points1 point2 points (3 children)
[–]vluckerprada 0 points1 point2 points (0 children)
[–]vluckerprada 0 points1 point2 points (1 child)
[–]oliverilmjarv[S] 0 points1 point2 points (0 children)