# Note: this Dockerfile is written to be executed with the whole source # as its context. # TODO remove client source # TODO material UI (and other libs) from CSN FROM node:12-alpine as frontend_builder # Make a static build of the front-end only. WORKDIR /usr/src/ COPY client/package*.json ./ RUN npm install --only=production COPY client/ ./ # Prime the front-end build to find the back-end at /api. ENV REACT_APP_BACKEND "/api" RUN GENERATE_SOURCEMAP=false npm run-script build FROM node:12-alpine # Some useful tools for servicing RUN apk update && apk upgrade && apk add bash # Install back-end dependencies WORKDIR /opt/mudbase/server COPY server/package*.json ./ RUN npm install --only=production # Install back-end source code WORKDIR /opt/mudbase/server COPY server/ ./ # Install static front-end build COPY --from=frontend_builder /usr/src/build /opt/mudbase/frontend # Install the API where the back-end expects # to find it. # TODO: can we move it somewhere else? COPY client/src/api.ts /opt/mudbase/client/src/api.ts # Install the runner script COPY deploy/run.sh /opt/mudbase/run.sh # Start WORKDIR /opt/mudbase EXPOSE 8080 ENV PORT 8080 ENV API "/api" ENV FRONTEND_PREFIX "/" ENV FRONTEND "/opt/mudbase/frontend" ENV NODE_ENV "production" ENV ENVIRONMENT "production" ENTRYPOINT './run.sh'