diff --git a/dev/README.md b/dev/README.md index d07960c..60e39df 100644 --- a/dev/README.md +++ b/dev/README.md @@ -70,14 +70,14 @@ The `docker-compose.yaml` file is constructed to prepare containers with all dep ```bash cd /home/node/app -npm start +npm run start ``` ### Backend-next `be_next` ```bash cd /home/node/app -npm start +npm run start ``` ### Frontend `fe` @@ -86,30 +86,30 @@ The frontend uses a custom Dockerfile with the following modifications: ```bash cd /frontend -npm start -- --host 0.0.0.0 +npm run start -- --host 0.0.0.0 --disable-host-check ``` -A custom Dockerfile is used because the production image uses the node alpine base image which does not crosscompile on macOS. +A custom Dockerfile is used because the production image builds the static site and then serves it via nginx. The development image serves the site using `ng serve` (webpack-dev-server) so it reflects the latest code and updates when files change. ### Search `search` ``` cd /home/node/app -npm start +npm run start ``` ### Landing Page `lp` ```bash cd /home/node/app -npm start -- --host 0.0.0.0 +npm run start -- --host 0.0.0.0 --disable-host-check ``` ### OAI-PMH `oi` ```bash cd /home/node/app -npm start +npm run start ``` ### Proposals `pr` diff --git a/dev/config/frontend/Dockerfile b/dev/config/frontend/Dockerfile index f492ac7..6bec3ff 100644 --- a/dev/config/frontend/Dockerfile +++ b/dev/config/frontend/Dockerfile @@ -1,22 +1,14 @@ FROM node:16 AS installer -WORKDIR /frontend -COPY package*.json /frontend/ -RUN npm ci -COPY . /frontend/ # A browser is needed for automated tests RUN apt-get update && apt-get install -y chromium ENV CHROME_BIN=/usr/bin/chromium ENV CHROME_PATH=/usr/lib/chromium/ -FROM node:16 AS builder WORKDIR /frontend -COPY --from=installer /frontend /frontend +COPY package*.json /frontend/ -RUN npx ng build +RUN npm ci -FROM nginx:1.12-alpine -RUN rm -rf /usr/share/nginx/html/* -COPY --from=builder /frontend/dist/ /usr/share/nginx/html/ -COPY scripts/nginx.conf /etc/nginx/nginx.conf -EXPOSE 80 +EXPOSE 4200 +CMD ["node serve"] \ No newline at end of file diff --git a/dev/docker-compose.yaml b/dev/docker-compose.yaml index 8400c27..8a1542e 100644 --- a/dev/docker-compose.yaml +++ b/dev/docker-compose.yaml @@ -63,15 +63,16 @@ services: build: context: ../frontend/. dockerfile: ../dev/config/frontend/Dockerfile - target: installer volumes: - ../frontend:/frontend - ./config/frontend/config.json:/frontend/src/assets/config.json - /frontend/node_modules - - /frontend/dist command: /bin/sh -c "while true; do sleep 600; done" ports: + # Dev image with `node start` uses port 4200 + # For the upstream dockerfile with nginx, use 4200:80 - 4200:4200 + profiles: - fe