Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to create a clean Dockerfile for razzle react app ? #916

Closed
nimahkh opened this issue Feb 6, 2019 · 5 comments
Closed

how to create a clean Dockerfile for razzle react app ? #916

nimahkh opened this issue Feb 6, 2019 · 5 comments

Comments

@nimahkh
Copy link

nimahkh commented Feb 6, 2019

hello my friends.
so ,after finishing my codings , how can I have a good Dockerfile for razzle? I try many configs and many ways, but answer is "error".
can somebody please help me to find a good Dockerfile for razzle?
thank you

@krazyjakee
Copy link

Razzle just produces a node server, so we can just aim to make a container for that.

Something as simple as this can suffice: https://gist.github.com/krazyjakee/4ebf64c479d66fcb110cfc69debad6ff

@sachaarbonel
Copy link

sachaarbonel commented Feb 12, 2019

@nimahkh @krazyjakee you can find a multi stage Dockerfile on my repo. I used the zeit pkg in order to reduce the size of the final image. There are also deployment scripts for kubernetes if you want.

@nimahkh nimahkh closed this as completed Feb 17, 2019
@iberodev
Copy link

I am having issues with this, but it's most likely due to my inexperience with docker and razzle.
I created the following Dockerfile for a basic razzle application with typescript:

FROM node:alpine
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app

ENV NODE_ENV production
ENV RAZZLE_CUSTOM_VARIABLE xxxxx

COPY package.json .

RUN npm install --production

COPY build ./build

EXPOSE 3000

CMD [ "node", "build/server.js" ]

I create the image with for example: docker build --tag=my-app:0.0.1 .

I get the following warning (not sure if related to my issue):

SECURITY WARNING: You are building a Docker image from Windows against a non-Windows Docker host. All files and directories added to build context will have '-rwxr-xr-x' permissions. It is recommended to double check and reset permissions for sensitive files and directories.

And finally I run my container with for example: docker run -p 3001:3000 my-app:0.0.1 and it executes properly.

When I go to localhost:30001 I can see my react application but without styles.
I can see a http://localhost:3003/static/css/bundle.b1e53d9a.css is being served, but it's empty
also the http://localhost:3003/static/js/bundle.fd36658a.js is empty and that must be the issue. The question is Why?

If I do a node build/server.js locally on my filesystem I can see the served react app on localhost:30001 working properly with styles.

Is this the correct approach to dockerize a razzle app? Am I missing something to have it working as expected? Sorry if my question is a silly one, as I said I am a bit ignorant in all this and hopefully this can be useful for others in a similar situatiion. Thanks!

@iberodev
Copy link

I've tried RUN chmod -R 755 ./build on my Dockerfile in case it had to do with permissions. No luck.

@nimahkh
Copy link
Author

nimahkh commented Aug 14, 2019

I've tried RUN chmod -R 755 ./build on my Dockerfile in case it had to do with permissions. No luck.

you have to create a user and install it with new user , look at here please
https://docs.docker.com/engine/reference/builder/#user

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants