diff --git a/Dockerfile b/Dockerfile index 0af8cdcb..548d3241 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,16 +1,18 @@ # ======================================= -FROM node:16-alpine AS deps +FROM registry.access.redhat.com/ubi8/nodejs-16 AS deps # ======================================= -# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed. -# USER node:0 -RUN apk add --no-cache libc6-compat +USER root +RUN yum install -y glibc-langpack-en curl --setopt=tsflags=nodocs && \ + curl --silent --location https://dl.yarnpkg.com/rpm/yarn.repo | tee /etc/yum.repos.d/yarn.repo && \ + yum -y install yarn --setopt=tsflags=nodocs && \ + yum clean all WORKDIR /app COPY package.json yarn.lock ./ RUN yarn install --frozen-lockfile # ======================================= -FROM node:16-alpine AS builder +FROM registry.access.redhat.com/ubi8/nodejs-16 AS builder # ======================================= # USER node:0 ARG NEXT_PUBLIC_DRUPAL_BASE_URL @@ -50,6 +52,10 @@ WORKDIR /app COPY . . COPY --from=deps /app/node_modules ./node_modules +# install yarn +USER root +RUN curl --silent --location https://dl.yarnpkg.com/rpm/yarn.repo | tee /etc/yum.repos.d/yarn.repo +RUN yum -y install yarn RUN yarn build # Prune dev & build deps until we can use Yarn 2 which does it on the next line @@ -58,16 +64,13 @@ RUN rm -rf node_modules RUN yarn install --production --ignore-scripts --prefer-offline # ======================================= -FROM node:16-alpine AS runner +FROM registry.access.redhat.com/ubi8/nodejs-16 AS runner # ======================================= WORKDIR /app # USER node:0 ENV NODE_ENV production ENV CACHE_REPOPULATE '1' -#DEBUG add curl to container for network debugging purposes -RUN apk --no-cache add curl - COPY --from=builder /app/.next ./.next COPY --from=builder /app/next.config.js ./next.config.js @@ -82,12 +85,14 @@ COPY --from=builder /app/logs ./logs # copy .env.production to runner so that runtime can have new env vars from repo if needed #COPY --from=builder /app/.env.production .env.production - # node process user should be able to write to .next/* +USER root +RUN curl --silent --location https://dl.yarnpkg.com/rpm/yarn.repo | tee /etc/yum.repos.d/yarn.repo +RUN yum -y install yarn + RUN chmod -R a+rwx ./.next RUN chmod -R a+rwx ./logs - EXPOSE 8080 ENV PORT=8080 diff --git a/azure-pipelines-stageprod.yml b/pipelines/infofinland-ui-production.yml similarity index 58% rename from azure-pipelines-stageprod.yml rename to pipelines/infofinland-ui-production.yml index e69ef257..b4e7ea79 100644 --- a/azure-pipelines-stageprod.yml +++ b/pipelines/infofinland-ui-production.yml @@ -1,13 +1,6 @@ # Continuous integration (CI) triggers cause a pipeline to run whenever you push # an update to the specified branches or you push specified tags. -trigger: - batch: true - branches: - include: - - main - paths: - exclude: - - README.md +trigger: none # Pull request (PR) triggers cause a pipeline to run whenever a pull request is # opened with one of the specified target branches, or when updates are made to @@ -23,13 +16,6 @@ pr: none # By default, use self-hosted agents pool: Default -# Image tag name for Fuse projects -#parameters: -#- name: imagetag -# displayName: Image tag to be built and/or deployed -# type: string -# default: latest - resources: repositories: # Azure DevOps repository @@ -39,9 +25,13 @@ resources: name: infofinland/infofinland-pipelines extends: - # Filename in Azure DevOps Repository (note possible -ui or -api) - # Django example: azure-pipelines-PROJECTNAME-api-release.yml - # Drupal example: azure-pipelines-drupal-release.yml - template: azure-pipelines-infofinland-ui-stageprod.yml@infofinland-pipelines - #parameters: - #imagetag: ${{ parameters.imagetag }} + # Filename in Azure DevOps Repository + template: components/infofinland-ui/pipelines/infofinland-ui-production.yml@infofinland-pipelines + # parameters: + # Application build arguments and config map values as key value pairs. + # Does not contain all buildArguments or configMap values, the rest located in infofinland-pipelines + # The values here will override the values defined in the infofinland-pipelines repository + # buildArgs: + # DEBUG: 1 + # configMap: # pod environment variables + # DEBUG: 1 diff --git a/azure-pipelines-test.yml b/pipelines/infofinland-ui-staging.yml similarity index 57% rename from azure-pipelines-test.yml rename to pipelines/infofinland-ui-staging.yml index 99866ebc..9e53af03 100644 --- a/azure-pipelines-test.yml +++ b/pipelines/infofinland-ui-staging.yml @@ -4,10 +4,13 @@ trigger: batch: true branches: include: - - dev + - main paths: exclude: - - README.md + - '*.md' + - '.github/' + - 'pipelines/infofinland-ui-production.yml' + - 'pipelines/infofinland-ui-test.yml' # Pull request (PR) triggers cause a pipeline to run whenever a pull request is # opened with one of the specified target branches, or when updates are made to @@ -23,13 +26,6 @@ pr: none # By default, use self-hosted agents pool: Default -# Image tag name for Fuse projects -#parameters: -#- name: imagetag -# displayName: Image tag to be built and/or deployed -# type: string -# default: latest - resources: repositories: # Azure DevOps repository @@ -39,10 +35,13 @@ resources: name: infofinland/infofinland-pipelines extends: - # Filename in Azure DevOps Repository (note possible -ui or -api) - # Django example: azure-pipelines-PROJECTNAME-api-master.yml - # Drupal example: azure-pipelines-drupal-master.yml - template: azure-pipelines-infofinland-ui-test.yml@infofinland-pipelines - # Image tag name for Fuse projects - #parameters: - #imagetag: ${{ parameters.imagetag }} + # Filename in Azure DevOps Repository + template: components/infofinland-ui/pipelines/infofinland-ui-staging.yml@infofinland-pipelines + # parameters: + # Application build arguments and config map values as key value pairs. + # Does not contain all buildArguments or configMap values, the rest located in infofinland-pipelines + # The values here will override the values defined in the infofinland-pipelines repository + # buildArgs: + # DEBUG: 1 + # configMap: # pod environment variables + # DEBUG: 1 diff --git a/azure-pipelines-devtest.yml b/pipelines/infofinland-ui-test.yml similarity index 58% rename from azure-pipelines-devtest.yml rename to pipelines/infofinland-ui-test.yml index a82c9b45..09d4a3cc 100644 --- a/azure-pipelines-devtest.yml +++ b/pipelines/infofinland-ui-test.yml @@ -7,7 +7,10 @@ trigger: - dev paths: exclude: - - README.md + - '*.md' + - '.github/' + - 'pipelines/infofinland-ui-production.yml' + - 'pipelines/infofinland-ui-staging.yml' # Pull request (PR) triggers cause a pipeline to run whenever a pull request is # opened with one of the specified target branches, or when updates are made to @@ -23,13 +26,6 @@ pr: none # By default, use self-hosted agents pool: Default -# Image tag name for Fuse projects -#parameters: -#- name: imagetag -# displayName: Image tag to be built and/or deployed -# type: string -# default: latest - resources: repositories: # Azure DevOps repository @@ -39,10 +35,13 @@ resources: name: infofinland/infofinland-pipelines extends: - # Filename in Azure DevOps Repository (note possible -ui or -api) - # Django example: azure-pipelines-PROJECTNAME-api-master.yml - # Drupal example: azure-pipelines-drupal-master.yml - template: azure-pipelines-infofinland-ui-devtest.yml@infofinland-pipelines - # Image tag name for Fuse projects - #parameters: - #imagetag: ${{ parameters.imagetag }} + # Filename in Azure DevOps Repository + template: components/infofinland-ui/pipelines/infofinland-ui-test.yml@infofinland-pipelines + # parameters: + # Application build arguments and config map values as key value pairs. + # Does not contain all buildArguments or configMap values, the rest located in infofinland-pipelines + # The values here will override the values defined in the infofinland-pipelines repository + # buildArgs: + # DEBUG: 1 + # configMap: # pod environment variables + # DEBUG: 1