Я работаю с Django и сейчас пытаюсь переместить моего локального разработчика. в докер. Мне удалось запустить мой веб-сервер. Однако то, что я еще не сделал, было npm install
. Вот где я застрял и не смог найти документацию или хорошие примеры. Кто-нибудь, кто делал это раньше?
Dockerfile
# Pull base image
FROM python:3.7
# Define environment variable
ENV PYTHONUNBUFFERED 1
RUN apt-get update && apt-get install -y \
# Language dependencies
gettext \
# In addition, when you clean up the apt cache by removing /var/lib/apt/lists
# it reduces the image size, since the apt cache is not stored in a layer.
&& rm -rf /var/lib/apt/lists/*
# Copy the current directory contents into the container at /app
COPY . /app
# Set the working directory to /app
WORKDIR /app
# Install Python dependencies
RUN pip install pipenv
RUN pipenv install --system --deploy --dev
COPY ./docker-entrypoint.sh /
RUN chmod +x /docker-entrypoint.sh
ENTRYPOINT ["/docker-entrypoint.sh"]
докер-Compose:
version: '3'
services:
db:
image: postgres
ports:
- "5432:5432"
environment:
# Password will be required if connecting from a different host
- POSTGRES_PASSWORD=django
web:
build: .
env_file: .env
volumes:
- .:/app
ports:
- "8000:8000"
depends_on:
- db
container_name: django
docker-entrypoint.sh
#!/bin/bash
# Apply database migrations
echo "Apply database migrations"
python manage.py migrate
# Run tests (In progress)
# echo "Running tests"
# pytest
# Start server
echo "Starting server"
python manage.py runserver 0.0.0.0:8000