diff --git a/www/Dockerfile b/www/Dockerfile index 14a8badbb..09e43c86b 100644 --- a/www/Dockerfile +++ b/www/Dockerfile @@ -1,5 +1,30 @@ # syntax=docker/dockerfile:1 +# #################### +# Web App - Build +# #################### +FROM node:16.8.0 as builder + +ARG API_ENDPOINT + +WORKDIR /usr/src/react_web_app +# copy npm package and lock file +COPY frontends/compiler_gym/package.json frontends/compiler_gym/package-lock.json ./ +RUN --mount=type=cache,target=/usr/src/react_web_app/.npm --mount=type=cache,target=/usr/src/react_web_app/node_modules \ + npm install + +# copy remaining UI code. +COPY frontends/compiler_gym/public public +COPY frontends/compiler_gym/src src + +# configure api endpoint +RUN echo REACT_APP_API_URL=${API_ENDPOINT} > .env.production + +# Compile frontend +RUN --mount=type=cache,target=/usr/src/react_web_app/.npm --mount=type=cache,target=/usr/src/react_web_app/node_modules \ + npm run build + + FROM python:3.8-slim-buster WORKDIR /app @@ -23,6 +48,6 @@ RUN pip3 install --no-cache-dir -r requirements.txt RUN python3 -m compiler_gym.bin.service --env=llvm-v0 COPY www.py . -COPY frontends/compiler_gym/build frontends/compiler_gym/build +COPY --from=builder /usr/src/react_web_app/build frontends/compiler_gym/build CMD [ "python3", "www.py"] diff --git a/www/frontends/compiler_gym/.dockerignore b/www/frontends/compiler_gym/.dockerignore new file mode 100644 index 000000000..07e6e472c --- /dev/null +++ b/www/frontends/compiler_gym/.dockerignore @@ -0,0 +1 @@ +/node_modules diff --git a/www/frontends/compiler_gym/.env.production b/www/frontends/compiler_gym/.env.production index b43179a08..d3b1961ad 100644 --- a/www/frontends/compiler_gym/.env.production +++ b/www/frontends/compiler_gym/.env.production @@ -1 +1 @@ -REACT_APP_API_URL=http://18.219.131.236:5000 +REACT_APP_API_URL=http://beanstalk-compiler-gym.eba-36iz7mga.us-east-2.elasticbeanstalk.com diff --git a/www/frontends/compiler_gym/package.json b/www/frontends/compiler_gym/package.json index 768d47eeb..373ca54a9 100644 --- a/www/frontends/compiler_gym/package.json +++ b/www/frontends/compiler_gym/package.json @@ -23,8 +23,8 @@ "web-vitals": "^1.1.2" }, "scripts": { - "start": "react-scripts --openssl-legacy-provider start", - "build": "react-scripts --openssl-legacy-provider build", + "start": "react-scripts start", + "build": "react-scripts build", "test": "react-scripts test", "eject": "react-scripts eject" }, diff --git a/www/www.py b/www/www.py index d080c07e4..a4f2dd08f 100644 --- a/www/www.py +++ b/www/www.py @@ -173,6 +173,11 @@ class StepReply(BaseModel): states: List[StateToVisualize] +@app.route("/health") +def healthy(): + return {'message': 'Healthy'} + + @app.route("/api/v4/describe") def describe(): with env_lock: