バックエンドとして Django/DRF、フロントエンドとして Angular に基づくアプリケーションを構築しています。Angular は Nginx によって実行されます。そして、docker-compose を使用して、このプロジェクトを DigitalOcean のドロップレットにデプロイしたいと考えています。プロジェクトの構造は次のとおりです。
price_comparison_tool/
├── backend
│ ├── accounts
│ ├── api
│ ├── price_tool_project
│ ├── static
│ ├── staticfiles
│ ├── db.sqlite3
│ ├── Dockerfile
│ ├── entrypoint.sh
│ ├── manage.py
│ └── requirements.txt
├── frontend
│ ├── e2e
│ ├── node_modules
│ ├── src
│ ├── angular.json
│ ├── CREDITS
│ ├── Dockerfile
│ ├── karma.conf.js
│ ├── LICENSE
│ ├── nginx.conf
│ ├── package.json
│ ├── package-lock.json
│ ├── README.md
│ ├── tsconfig.app.json
│ ├── tsconfig.json
│ ├── tsconfig.spec.json
│ └── tslint.json
└── docker-compose.yml
frontend
Dockerfileの内容は次のとおりです。
FROM node:14-alpine as build
RUN mkdir -p /usr/src/app
# Change directory so that our commands run inside this new directory
WORKDIR /usr/src/app
COPY package.json /usr/src/app
RUN npm install
COPY . /usr/src/app
RUN npm run build-prod
FROM nginx:1.17
COPY --from=build /usr/src/app/dist /usr/share/nginx/html/
COPY nginx.conf /etc/nginx/nginx.conf
EXPOSE 3000
ENTRYPOINT ["nginx", "-g", "daemon off;"]
そして、ここに私が持っているものdocker-compose.yml
:
version: '3.7'
services:
api:
build: ./backend
ports:
- "8000:8000"
volumes:
- ./backend:/code
web:
build: ./frontend
volumes:
- .:/frontend
ports:
- "80:80"
depends_on:
- api
docker-compose up --build
自分のマシン (Ubuntu 20.04) でローカルに実行すると、すべてが正常にビルドおよび実行されます。プロジェクトは url0.0.0.0
で、API は で表示され0.0.0.0:8000
ます。しかし、DigitalOcean のドロップレットで同じことを行うと、次のエラーが発生します。
Step 9/13 : FROM nginx:1.17
---> 9beeba249f3e
Step 10/13 : COPY --from=build /usr/src/app/dist/ /usr/share/nginx/html/
ERROR: Service 'web' failed to build: COPY failed: stat usr/src/app/dist/: file does not exist
誰かが私が間違っていることを指摘できますか? これは、Docker と Docker-compose、そして DigitalOcean での私の最初の経験です...
前もって感謝します!