Please, can someone help me?
I just started learning Django-REST-API using Docker. I want to install postgresql-11-alpine but i keep getting this error messages when i run; docker-compose build:
WARNING: Ignoring http://dl-cdn.alpinelinux.org/alpine/v3.12/main/x86_64/APKINDEX.tar.gz: temporary error (try again later) WARNING: Ignoring http://dl-cdn.alpinelinux.org/alpine/v3.12/community/x86_64/APKINDEX.tar.gz: temporary error (try again later) ERROR: unsatisfiable constraints: postgresql-client (missing): required by: world[postgresql-client] ERROR: Service 'app' failed to build: The command '/bin/sh -c apk add --update --no-cache postgresql-client' returned a non-zero code: 1
Below is my Dockerfile
file
FROM python:3.7-alpine
MAINTAINER Tboost Technology
#set environment variable
ENV PYTHONUNBUFFERED 1
#install dependencies
COPY ./requirements.txt /requirements.txt
RUN apk add --update --no-cache postgresql-client
RUN apk add --update --no-cache --virtual .tmp-build-deps \
gcc libc-dev python3-dev linux-headers postgresql-dev
RUN pip3 install -r /requirements.txt
RUN apk del .tmp-build-deps
#mkdir to store your apps source code
RUN mkdir /app
WORKDIR /app
COPY ./app /app
#create user to run apps in the docker
RUN adduser -D user
#switch to the user
USER user
Below is my docker-compose.yml
file
version: "3"
services:
app:
build:
context: .
ports:
- "8000:8000"
extra_hosts:
- "host.docker.internal:172.17.0.1"
volumes:
- ./app:/app
command: >
sh -c "python manage.py runserver 0.0.0.0:8000"
environment:
- DB_HOST=db
- DB_NAME=app
- DB_USER=postgres
- DB_PASS=supersecretpassword
depends_on:
- db
db:
image: postgres:11-alpine
restart: always
environment:
- POSTGRES_DB=app
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=supersecretpassword
My requirements.txt
file:
Django>=3.0.7,<3.0.8
djangorestframework>=3.11.0,<3.12.0
psycopg2>=2.7.5,<2.8.0
flake8>=3.6.0,<3.7.0
Thanks.