【发布时间】:2020-05-19 21:03:41
【问题描述】:
我创建了一个带有 Angular 前端和基于 django rest 框架的后端的应用程序。 我已经为它们创建了一个图像,并且它们使用 docker 运行良好。 av-app-multistage 容器是 angular 容器,服务器是 django 后端。
要运行这个应用程序,我必须单独启动它们。我怎样才能创建某种脚本来自动化这个过程。这样如果我运行 angular 容器,它会自动运行后端??
这是我的 dockerfile。 这是 django 的 docker 文件
FROM python:3.6
# The enviroment variable ensures that the python output is set straight
# to the terminal with out buffering it first
ENV PYTHONUNBUFFERED 1
# create root directory for our project in the container
RUN mkdir /app_service
# Set the working directory to /music_service
WORKDIR /app_service
# Copy the current directory contents into the container at /music_service
ADD . /app_service/
# Install any needed packages specified in requirements.txt
RUN pip install -r requirements.txt
这是 django 的 docker compose 文件
version: '3'
services:
web:
build: .
command: bash -c "python manage.py makemigrations && python manage.py migrate && python manage.py runserver 0.0.0.0:8000"
container_name: app_service
volumes:
- .:/app_service
ports:
- "8000:8000"
这是 Angular 的 docker 文件
FROM node:10.16-alpine AS build
WORKDIR /usr/src/app
COPY package.json ./
RUN npm install
COPY . .
RUN npm run build
### STAGE 2: Run ###
FROM nginx:1.17.1-alpine
COPY --from=build /usr/src/app/dist/movie-info-service /usr/share/nginx/html
【问题讨论】:
标签: docker docker-compose dockerfile