GithubHelp home page GithubHelp logo

Comments (10)

anmonteiro avatar anmonteiro commented on May 17, 2024

Does this work with the stock create-react-app (in JS)?

from reason-scripts.

rrdelaney avatar rrdelaney commented on May 17, 2024

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!

from reason-scripts.

portenez avatar portenez commented on May 17, 2024

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.

from reason-scripts.

rrdelaney avatar rrdelaney commented on May 17, 2024

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.

from reason-scripts.

portenez avatar portenez commented on May 17, 2024

Create React App versions

working = YES

Version 1 with npx

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

Version 2 with yarn

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

To run

  1. Create a Dockerfile with the code above
  2. Build image using the Dockerfile. e.g.: docker build . -t happy-js
  3. yarn start succeeds. try by: docker run --rm -it happy-js yarn start
  4. yarn build fails. try by: 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.

from reason-scripts.

portenez avatar portenez commented on May 17, 2024

@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:

  1. Get/install docker: https://www.docker.com/docker-mac
  2. In a dir touch 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.
  3. Build the container by calling docker build in the same dir as the Dockerfile docker build . -t ${tagUseAsRefToRun}.
  4. Run the built container by using docker run: 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

from reason-scripts.

rrdelaney avatar rrdelaney commented on May 17, 2024

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 rrdelaney/bs-loader#35 and gliderlabs/docker-alpine#160 for more information.

from reason-scripts.

portenez avatar portenez commented on May 17, 2024

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?

from reason-scripts.

portenez avatar portenez commented on May 17, 2024

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 [email protected]
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

from reason-scripts.

anmonteiro avatar anmonteiro commented on May 17, 2024

@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.

from reason-scripts.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.