bcgov / NRPTI

Natural Resources Public Transparency Initiative
Apache License 2.0
5 stars 15 forks source link

Dockerize Front End portion of NRPTI Repo #1151

Open jakemorr opened 10 months ago

jakemorr commented 10 months ago

Describe the task Dockerizing the front end allows developers to more easily run NRPTI locally, creates a more consistent local instance

Acceptance Criteria

Additional context

LocalNewsTV commented 8 months ago

This ticket is being worked on casually and is considered low priority

LocalNewsTV commented 7 months ago

Cannot get NRPTI Frontend to dockerize despite attempts with(out) using nginx. Given this is intended for developers who are given the same equipment to work off of and nrpti often has to be rebuilt when changes are made, the value add is low.

LocalNewsTV commented 7 months ago

Findings

Approach One

FROM node:14.21.3 AS build

RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash \
    && export NVM_DIR="$HOME/.nvm" \
    && [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" \
    && nvm install 14.21.3

WORKDIR /app

COPY ./package*.json .
RUN npm install @angular/cli@7.3.7 -g

COPY . .

RUN npm ci
RUN npm run build:library:dev

EXPOSE 4200:4200
EXPOSE 4300:4300
EXPOSE 4400:4400

CMD [ "npm", "start", "--host=0.0.0.0" ]

Dockerfile would build and load, but pages were unaccessible

Approach Two

continuation of stage one, using a multi-stage build with nginx (appended to end of previous example)

## Stage 2: Nginx state for serving content
FROM nginx:alpine

# copy custom nginx configuration from host to container
COPY nginx.conf /etc/nginx/conf.d/default.conf

# Set working directory to nginx asset directory
WORKDIR /usr/share/nginx/html

# Remove default nginx static assets
RUN rm -rf ./*

COPY --from=build . .

RUN chmod g+rwx /var/cache/nginx /var/run /var/log/nginx

ENTRYPOINT ["nginx", "-g", "daemon off;"]

Resulted in Internal Server errors