FROM python:alpine
ENV PYTHONUNBUFFERED 1
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 linux-headers postgresql-dev
RUN pip install -r /requirements.txt
RUN apk del .tmp-build.deps
RUN mkdir /app
WORKDIR /app
COPY ./app /app
RUN adduser -D user
USER user
Create user for running application only
RUN adduser -D user
USER user
Add dependency of psycopg2
If not run the command below, it can't install psycopg2 within the file requirements.txt
RUN apk add --update --no-cache --virtual .tmp-build.deps \
gcc libc-dev linux-headers postgresql-dev
The apk is apache package
The meaning of this command , it is installed into packages, those packages aren't added to global packages, it easy to manage.
apk add --update --no-cache --virtual .tmp-build.deps gcc libc-dev linux-headers postgresql-dev
This command is delete package
RUN apk del .tmp-build.deps
This is example file the docker-compose.yml for use this image
version: "3"
services:
app:
build:
context: .
ports:
- "8000:8000"
volumes:
- ./app:/app
command: >
sh -c "python manage.py runserver 0.0.0.0:8000"
Run docker compose for create project by django into your current directory in container
docker-compose run app sh -c "django-admin.py startproject app ."
Content type
Image
Digest
Size
96.8 MB
Last updated
over 6 years ago
docker pull rosered/python