장고가 도커와 커뮤니케이팅 하기 위해서 약간의 dependencies를 빌드해보도록 할게요.
외부 패키지를 다운 받아야하는데요.
더불어 장고와 postgres간의 통신에 필요한 여러 의존성 패키지들도 설치해줘야 해요.
아래 한 줄을 삽입 해주도록 할게요.
psycopg2>=2.7.5,<2.8.0
변경 후
Django>=2.1.3,<2.2.0
djangorestframework>=3.9.0,<3.10.0
psycopg2>=2.7.5,<2.8.0
flake8>=3.6.0,<3.7.0
변경 전
FROM python:3.7-alpine
LABEL maintainer="someone@something.com"
ENV PYTHONUNBUFFERED 1
COPY ./requirements.txt /requirements.txt
RUN pip install -r /requirements.txt
RUN mkdir /app
WORKDIR /app
COPY ./app /app
RUN adduser -D user
USER user
변경 후
중간에 안보이던 apk명령어가 보이조.
아래 구체적인 --update --no-cache같은 옵션 및 특징들을 알고 싶다면 여기를 클릭해주세요.
FROM python:3.7-alpine
LABEL maintainer="someone@something.com"
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
그리고
docker-compose build
명령어를 넣도록 할게요.
The following only builds the images, does not start the containers:
docker-compose build
The following builds the images if the images do not exist and starts the containers:
docker-compose up
If you add the --build option, it is forced to build the images even when not needed:
docker-compose up --build
The following skips the image build process:
docker-compose up --no-build
If the images aren't built beforehand, it fails.
The --no-cache
option disables the Docker build cache in the image creation process. This is used to cache each layer in the Dockerfile and to speed up the image creation reusing layers (~ Dockerfile lines) previously built for other images that are identical.