Closed portenez closed 6 years ago
Does this work with the stock create-react-app
(in JS)?
Hi @portenez, thanks for filing this issue!
Could you please paste the full output of the error logs? I don't know if any of the maintainers here use Docker, and installing it to debug this issue would be a serious time commitment from us. Additionally, pasting the error logs could give us a lot for information and we can tell if it's a known issue from Reason, or from the upstream create-react-app.
I also recommend searching the create-react-app repo for more information on using it with Docker.
Thanks again!
Create react app does work. I have another project with a similar setup (create react app) , but no reasonml. that one work just fine. I'll double check versions and post a dockerfile for that one (just create react app) as soon as I have a chance. How do I enable the debug logs? I'll post them here.
You said the “start” command fails? What do yoya mean by fails? This is a difficult and time consuming set up to replicate, so we would appreciate knowing how it fails, there may be a different error than just running it in docket.
working = YES
FROM node:9-alpine
RUN addgroup -S app && adduser -S -G app app
USER app
RUN mkdir ~/.npm-global
RUN npm config set prefix '~/.npm-global'
ENV PATH=~/.npm-global/bin:$PATH
RUN cd ~ \
&& npx create-react-app my-app
WORKDIR /home/app/my-app
FROM node:9-alpine
RUN addgroup -S app && adduser -S -G app app
USER app
RUN mkdir ~/.npm-global
RUN npm config set prefix '~/.npm-global'
ENV PATH=~/.npm-global/bin:$PATH
RUN cd ~ \
&& yarn create react-app my-app
WORKDIR /home/app/my-app
Dockerfile
with the code abovedocker build . -t happy-js
docker run --rm -it happy-js yarn start
docker run --rm -it happy-js yarn build
Sample succesful output:
docker run --rm -it happy-js yarn build 8s 148ms
yarn run v1.5.1
$ react-scripts build
Creating an optimized production build...
Compiled successfully.
File sizes after gzip:
36.94 KB build/static/js/main.a0b7d8d3.js
299 B build/static/css/main.c17080f1.css
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:
yarn global add serve
serve -s build
Find out more about deployment here:
http://bit.ly/2vY88Kr
Done in 9.46s.
@rrdelaney I updated the original ticket with the output that I'm getting.
More than docker, looks like a Linux issue. To replicate any of the scenarios pretty much these are the steps:
Dockerfile
, and add the contents of any of my examples. At this point you have docker + the Dockefile with the instructions on how to create the container.Dockerfile
docker build . -t ${tagUseAsRefToRun}
.docker run --rm -it ${tagUseAsRefToRun} ${comandsToExecute}
. So for example
mkdir dockerTest
cd dockerTest
touch Dockerfile
vim Dockerfile #here paste the contents
docker build . -t test-container
docker run --rm -it test-container yarn start # the last tokens in the cli are passed to the container
#or
docker run --rm -it test-container yarn build
An alternative way to reproduce it is to just open a terminal in node:9-alpine and type all the commands in there. More difficult IMO.
You could start such terminal by:
docker run --rm -it node:9-alpine /bin/ash
Which will give you a completely clean node:9-alpine container
It looks like Alpine Linux doesn’t have the script command. reason-scripts running on Linux system requires that command to be present.
Please see https://github.com/reasonml-community/bs-loader/issues/35 and https://github.com/gliderlabs/docker-alpine/issues/160 for more information.
I see, that's a shame. I guess I'm going to try using debían instead. Thanks for the help.
Perhaps, it'd be useful to have some Linux info in the docs. Or maybe I missed it?
As reference, xenial
based container did work just fine:
FROM ubuntu:xenial
RUN apt-get update \
&& apt-get install -y curl \
build-essential \
git \
&& apt-get clean \
&& apt-get autoremove --purge
RUN curl -sL https://deb.nodesource.com/setup_9.x | bash - \
&& apt-get install -y nodejs \
&& apt-get clean
RUN npm install -g yarn
RUN yarn add global reason-cli@3.2.0-linux
RUN yarn add global bs-platform
RUN mkdir -p /opt \
&& yarn create react-app my-app --scripts-version reason-scripts \
&& cd my-app
WORKDIR /opt/my-app
CMD ["yarn", "start"]
build contianerdocker build . -t reason-builder
serve docker run --rm -it reason-builder
build assets docker run --rm -it reson-builder yarn build
@portenez I just ran into this myself and apk add util-linux
adds script
for me. Perhaps that's an alternative for you if you wanna get a slimmer container.
yarn start
andyarn build
both fail inside a docker container built using the instructions in the docs. Running inside alpine is a must for compiling inside a CI pipeline.To reproduce:
Dockerfile
. e.g.:docker build . -t sad-reson
yarn start
fails. try by:docker run --rm -it sad-reason yarn start
yarn build
fails. try by:docker run --rm -it sad-reason yarn build
Sample error: