Skip to content
Snippets Groups Projects
next-kubernetes.yml 944 B
Newer Older
  • Learn to ignore specific revisions
  • include:
    
    Marco's avatar
    Marco committed
      - project: gitlab-ci/kubernetes-base
    
    Marco's avatar
    Marco committed
        ref: v5
    
    Marco's avatar
    Marco committed
        file: panter-kubernetes-base.yml
    
    .ensureDocker: &ensureDocker |
      function ensureDockerfile() {
    
        if [ ! -f .dockerignore ]; then 
          cat > .dockerignore <<EOF
      node_modules
      .git
      
      EOF
        fi
    
        
        if [ ! -f .nvmrc ]; then 
          NODE_VERSION=14
        else
          NODE_VERSION="$(cat .nvmrc| sed '/^$/d' | sed 's/[a-z-]//g')"
        fi
        
    
    Marco's avatar
    Marco committed
        if [ ! -f Dockerfile ]; then
          echo "Creating Dockerfile"
          
          cat > Dockerfile <<EOF
    
      FROM node:$NODE_VERSION-alpine
    
      WORKDIR /app
    
      RUN apk add --no-cache git
      COPY --chown=node:node package.json yarn.lock ./
      RUN chown -R node:node .
      USER node
    
      RUN yarn --frozen-lockfile --production=true --ignore-scripts
    
      COPY --chown=node:node . .
      RUN yarn --frozen-lockfile --production=true
    
    
    Marco Wettstein's avatar
    Marco Wettstein committed
      EOF
    
    Marco's avatar
    Marco committed
        fi
    
      }
    
    
    docker-build:
    
    Marco's avatar
    Marco committed
      extends: .docker-build
    
      before_script:
    
    Marco's avatar
    Marco committed
        - *ensureDocker
        - ensureDockerfile