Home > Software engineering >  When push to heroku container - huge amount of data is generated
When push to heroku container - huge amount of data is generated

Time:03-23

i am pushing react app to heroku container. Build itself is of course relatively small.

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

but when i'm running heroku container:push -a app-name web incredible sizes are generated

=== 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

when working from mobile - it hurts.

is it like this for everyone or am i doing it wrong?

thanks

edit: Dockerfile used

FROM node:alpine

# app inside container
WORKDIR "/app"

COPY ./package.json ./

RUN npm install

COPY . .

RUN npm run build

CMD [ "npm", "run", "start:prod" ]

working part of package.json/scripts "start:prod": "serve -s build",

CodePudding user response:

Use a .dockerignore file (same directory as the Dockerfile) to exclude unnecessary content from the Docker image

.env
.github
node_modules

Check if you can add other folders/files (docs?)

  • Related