Я хотел бы создать Dockerfile, который создает файлы stati c для реагирующего приложения и скопировать его в другое изображение.
Когда я запускаю docker-compose up
с файлами ниже, я нахожу, что В контейнере nginx нет файлов, которые я хочу в /config/www
. Есть идеи, что мне не хватает?
docker -compose.yml
version: '3.7'
services:
api:
build:
context: ./api
dockerfile: Dockerfile-prod
volumes:
- ./db:/usr/src/app/db
ports:
- 5000
environment:
- FLASK_ENV=production
- EMAIL_USERNAME=${EMAIL_USERNAME}
- EMAIL_PASSWORD=${EMAIL_PASSWORD}
- JWT_SECRET_KEY=${JWT_SECRET_KEY}
- JWT_COOKIE_DOMAIN=${JWT_COOKIE_DOMAIN}
- ADMIN_USERNAME=${ADMIN_USERNAME}
- ADMIN_PASSWORD=${ADMIN_PASSWORD}
# client:
# build:
# context: ./client
# dockerfile: Dockerfile-prod
# volumes:
# - react:/usr/src/app/build
# environment:
# - NODE_ENV=production
nginx:
build:
context: ./
dockerfile: Dockerfile-prod
container_name: nginx
ports:
- 80:80
- 443:443
restart: unless-stopped
volumes:
# - react:/config/www
- ./nginx/prod.conf:/config/nginx/site-confs/default
environment:
- PUID=1050
- PGID=1050
- URL=${JWT_COOKIE_DOMAIN}
- TZ=Australia/Sydney
depends_on:
- api
# volumes:
# react:
Dockerfile-prod
FROM node:10.16.0-alpine AS build
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
ENV PATH /usr/src/app/node_modules/.bin:$PATH
ADD client /usr/src/app
RUN npm install
RUN npm run build
FROM linuxserver/letsencrypt
COPY --from=build /usr/src/app/build /config/www
вывод сборки
Step 7/9 : RUN npm run build
---> Running in 555e104b262d
> learning@1.3.0 build /usr/src/app
> react-scripts build
Creating an optimized production build...
Compiled successfully.
File sizes after gzip:
150.58 KB (-11.48 KB) build/static/js/2.c3a02695.chunk.js
18.89 KB (-2.06 KB) build/static/js/main.7370b4bd.chunk.js
18.7 KB (-128 B) build/static/css/2.0ce8856a.chunk.css
17.2 KB (-807 B) build/static/css/main.7a2495bd.chunk.css
762 B build/static/js/runtime~main.a8a9905a.js
The project was built assuming it is hosted at the server root.
You can control this with the homepage field in your package.json.
For example, add this to build it for GitHub Pages:
"homepage" : "http://myname.github.io/myapp",
The build folder is ready to be deployed.
You may serve it with a static server:
npm install -g serve
serve -s build
Find out more about deployment here:
https://********
Removing intermediate container 555e104b262d
---> 56f493772583
Step 8/9 : FROM linuxserver/letsencrypt
---> 17f7eabbfdf4
Step 9/9 : COPY --from=build /usr/src/app/build /config/www
---> e4f875f96fd3
Successfully built e4f875f96fd3
Successfully tagged learning_nginx:latest