я нажимаю реагирующее приложение на контейнер heroku. Сама сборка конечно относительно небольшая.
pl@hp:~/Desktop/proj/node/fastify-react/build$ du -h .
12K ./static/css
1,5M ./static/js
144K ./static/media
1,6M ./static
1,7M
но когда я бегу heroku container:push -a app-name web
генерируются невероятные размеры
=== Building web (/home/pl/Desktop/proj/node/fastify-react/Dockerfile)
Sending build context to Docker daemon 483.2MB
Step 1/7 : FROM node:alpine
---> eb56d56623e5
Step 2/7 : WORKDIR "/app"
---> Using cache
---> 38bd51aaed88
Step 3/7 : COPY ./package.json ./
---> Using cache
---> 246322cb9686
Step 4/7 : RUN npm install
---> Using cache
---> 5ef408ff8fa5
Step 5/7 : COPY . .
---> a82bbd411ea8
Step 6/7 : RUN npm run build
---> Running in a5d6474a0245
> [email protected] build
> react-scripts build
Creating an optimized production build...
Compiled successfully.
File sizes after gzip:
89.17 kB build/static/js/main.e7da8d06.js
593 B build/static/css/main.03f19716.css
The project was built assuming it is hosted at /.
You can control this with the homepage field in your package.json.
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://cra.link/deployment
Removing intermediate container a5d6474a0245
---> 8fa1467e608a
Step 7/7 : CMD [ "npm", "run", "start:prod" ]
---> Running in ee255298f781
Removing intermediate container ee255298f781
---> 592c31461609
Successfully built 592c31461609
Successfully tagged registry.heroku.com/xxxxxxxx/web:latest
=== Pushing web (/home/pl/Desktop/proj/node/fastify-react/Dockerfile)
Using default tag: latest
The push refers to repository [registry.heroku.com/xxxxxxx/web]
efb0d1b2452c: Pushed
42a09a41407b: Pushing 424.2MB/424.2MB
a4e981a118e3: Pushing 342.3MB/397.3MB
1711b045f67a: Layer already exists
ce175d7bc2d9: Layer already exists
44811d973ddb: Layer already exists
92dbba4d44e2: Layer already exists
b53051d49599: Layer already exists
8d3ac3489996: Layer already exists
write tcp 192.168.187.221:52056->54.210.119.52:443: write: connection reset by peer
▸ Error: docker push exited with Error: 1
при работе с мобильного - больно.
это у всех так или я что то не так делаю?
спасибо
редактировать: Dockerfile используется
FROM node:alpine
# app inside container
WORKDIR "/app"
COPY ./package.json ./
RUN npm install
COPY . .
RUN npm run build
CMD [ "npm", "run", "start:prod" ]
рабочая часть package.json/scripts
"start:prod": "serve -s build",
@Wraithy добавил пример Dockerfile в редактирование. Спасибо
Используйте файл .dockerignore
(тот же каталог, что и Dockerfile), чтобы исключить ненужный контент из образа Docker.
.env
.github
node_modules
Проверьте, можете ли вы добавить другие папки/файлы (документы?)
это определенно работает, я добавил, что .dockerignore
и журнал стал немного лучше ``` Push ссылается на репозиторий [registry.heroku.com/xxxxxx/web] b8b4e2fa1003: отправка 7,619 МБ/17,35 МБ a4e981a118e3: Нажатие 9,686 МБ/397,3 МБ```, но все еще есть большие числа. в любом случае, спасибо
Похоже, что вы обслуживаете свое приложение в состоянии «не построено». Это означает, что heroku, вероятно, загружает целые node_modules. Можете ли вы показать нам пример из вашего файла докеров?