I'm trying to deploy my dockerized API to Portainer via Git but some images in my docker-compose.yml are getting published while others aren't. Why?

Viewed 330

I have a Django API that is completely dockerized and it works locally as well as in my Heroku deployment for production. However when I try to connect the Git repo to Portainer, it is able to successfully pull it but it doesn't publish all the images. It is only able to give the port for the pgadmin image, not for the database or the redis image or the nginx or the django web service itself. These are things I need to get the whole thing working. I'm not sure what's wrong or what to do about it.

This is my docker-compose.yml file:-

version: "3.9"

services:
  nginx:
    build: ./nginx
    ports:
      - 8001:80
    volumes:
      - static-data:/vol/static
    depends_on:
      - web
    restart: "on-failure"

  redis:
    image: redis:latest
    ports:
      - 6379:6379
    volumes:
      - ./config/redis.conf:/redis.conf
    command: ["redis-server", "/redis.conf"]
    restart: "on-failure"

  db:
    image: postgres:13
    volumes:
      - ./data/db:/var/lib/postgresql/data
    env_file:
      - database.env
    restart: always

  web:
    build: .
    command: bash -c "python manage.py makemigrations && python manage.py migrate && python manage.py runserver 0.0.0.0:8101"
    container_name: vidhya_io_api
    volumes:
      - .:/shuddhi
    ports:
      - 8101:8101
    depends_on:
      - db
      - redis
    restart: "on-failure"

volumes:
  database-data: # named volumes can be managed easier using docker-compose
  static-data:

This is the Dockerfile:-

FROM python:3.8.3
LABEL maintainer="https://github.com/ryarasi"
# ENV MICRO_SERVICE=/app
# RUN addgroup -S $APP_USER && adduser -S $APP_USER -G $APP_USER
# set work directory


# set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

COPY ./requirements.txt /requirements.txt
# create root directory for our project in the container
RUN mkdir /shuddhi
# COPY ./scripts /scripts
WORKDIR /shuddhi

# Copy the current directory contents into the container at /shuddhi
ADD . /shuddhi/
# Install any needed packages specified in requirements.txt

# This is to create the collectstatic folder for whitenoise
RUN pip install --upgrade pip && \
    pip install --no-cache-dir -r /requirements.txt && \
    mkdir -p /vol/web/static && \
    mkdir -p /vol/web/media

# ENV PATH="/scripts:$PATH"
# CMD ["run.sh"]

CMD python manage.py wait_for_db && python manage.py collectstatic --noinput && python manage.py migrate && gunicorn shuddhi.wsgi:application --bind 0.0.0.0:8101

After I set up the stack and run it, this is what I see:-

screenshot of portainer container with publish ports

You can see that the published ports are missing for all the images other than the Redis image.

I have no idea why this is happening.

What should I do to get it all published and working?

0 Answers
Related