refactor: move node and builder images

This commit is contained in:
2023-07-03 14:36:47 +02:00
parent 4e4c7b5cc9
commit 11c9d742cd
26 changed files with 239 additions and 448 deletions

View File

@@ -1,105 +1,3 @@
image: registry.gitlab.com/openstapps/projectmanagement/node
before_script:
- npm ci
default:
tags:
- performance
stages:
- build
- test
- maintenance
- audit
- publish
- deploy
npm build:
stage: build
script:
- npm run build
artifacts:
paths:
- lib
npm test:
script:
- npm run test
stage: test
docker image builder:
image: registry.gitlab.com/openstapps/projectmanagement/builder
stage: build
only:
variables:
- $BUILD_IMAGES == "true"
variables:
DOCKER_DRIVER: overlay2
services:
- docker:dind
script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN registry.gitlab.com
- docker build -t registry.gitlab.com/openstapps/projectmanagement/builder -f images/builder/Dockerfile .
- docker push registry.gitlab.com/openstapps/projectmanagement/builder
tags:
- secrecy
docker image node:
image: registry.gitlab.com/openstapps/projectmanagement/builder
stage: build
only:
variables:
- $BUILD_IMAGES == "true"
variables:
DOCKER_DRIVER: overlay2
services:
- docker:dind
script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN registry.gitlab.com/openstapps/projectmanagement/
- docker build -t registry.gitlab.com/openstapps/projectmanagement/node -f images/node/Dockerfile images/node
- docker push registry.gitlab.com/openstapps/projectmanagement/node
tags:
- secrecy
docker image cypress:
image: registry.gitlab.com/openstapps/projectmanagement/builder
stage: build
only:
variables:
- $BUILD_IMAGES == "true"
variables:
DOCKER_DRIVER: overlay2
services:
- docker:dind
script:
- export CHROME_VERSION=$(curl -fsSL https://versionhistory.googleapis.com/v1/chrome/platforms/linux/channels/stable/versions | jq -r '.versions[0].version')
- export FIREFOX_VERSION=$(curl -fsSL https://product-details.mozilla.org/1.0/firefox_versions.json | jq -r '.LATEST_FIREFOX_VERSION')
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN registry.gitlab.com/openstapps/projectmanagement/
- docker build --build-arg CHROME_VERSION=$CHROME_VERSION --build-arg FIREFOX_VERSION=$FIREFOX_VERSION -t registry.gitlab.com/openstapps/projectmanagement/cypress -f images/cypress/Dockerfile images/cypress
- docker push registry.gitlab.com/openstapps/projectmanagement/cypress
tags:
- secrecy
npm audit:
allow_failure: true
except:
- schedules
script:
- npm audit
stage: audit
scheduled npm audit:
only:
- schedules
except:
variables:
- $MAINTENANCE_MODE
- $RENOVATE
script:
- npm audit --production
stage: audit
tidy:
script:
- node lib/cli tidy
@@ -131,32 +29,6 @@ unlabel:
tags:
- secrecy
pages:
stage: deploy
script:
- npm run documentation
- mv docs public
only:
- /^v[0-9]+\.[0-9]+\.[0-9]+$/
artifacts:
paths:
- public
npm package:
dependencies:
- npm build
tags:
- secrecy
stage: publish
script:
- echo "//registry.npmjs.org/:_authToken=$NPM_AUTH_TOKEN" > ~/.npmrc
- npm publish
only:
- /^v[0-9]+.[0-9]+.[0-9]+$/
artifacts:
paths:
- lib
renovate:
image: renovate/renovate:slim
services:

View File

@@ -1,22 +0,0 @@
FROM docker/compose
ARG NODE_VERSION="14"
RUN apk update && apk add nodejs npm git jq curl
RUN export DOWNLOAD_VERSION=$(curl -fsSL --compressed https://unofficial-builds.nodejs.org/download/release/index.json | \
jq --raw-output ".[]|select(.version | startswith(\"v$NODE_VERSION\"))|.version" | head -1) && \
curl -fsSLO --compressed "https://unofficial-builds.nodejs.org/download/release/$DOWNLOAD_VERSION/node-$DOWNLOAD_VERSION-linux-x64-musl.tar.xz" && \
tar -xJf "node-$DOWNLOAD_VERSION-linux-x64-musl.tar.xz" -C /usr/local --strip-components=1 --no-same-owner && \
ln -sf /usr/local/bin/node /usr/local/bin/nodejs
ADD . /opt/openstapps/projectmanagement
WORKDIR /opt/openstapps/projectmanagement
RUN npm ci && \
npm run build && \
chmod +x /opt/openstapps/projectmanagement/lib/cli.js && \
ln -s /opt/openstapps/projectmanagement/lib/cli.js /usr/bin/openstapps-projectmanagement
CMD []

View File

@@ -1,101 +0,0 @@
# WARNING: this file was autogenerated by generate-browser-image.js
# using
# yarn add:browser -- 14.19.0 --chrome=100.0.4896.88 --firefox=99.0.1 --edge
#
# build args added afterwards
#
FROM cypress/base:14.21.1
ARG CHROME_VERSION="unknown"
ARG FIREFOX_VERSION="unknown"
USER root
RUN node --version
# Install dependencies
RUN apt-get update && \
apt-get install -y \
fonts-liberation \
git \
libcurl4 \
libcurl3-gnutls \
libcurl3-nss \
xdg-utils \
wget \
curl \
# firefox dependencies
bzip2 \
# add codecs needed for video playback in firefox
# https://github.com/cypress-io/cypress-docker-images/issues/150
mplayer \
# edge dependencies
gnupg \
dirmngr \
# clean up
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean
# install libappindicator3-1 - not included with Debian 11
RUN wget --no-verbose -O /usr/src/libappindicator3-1_0.4.92-7_amd64.deb "http://ftp.us.debian.org/debian/pool/main/liba/libappindicator/libappindicator3-1_0.4.92-7_amd64.deb" && \
dpkg -i /usr/src/libappindicator3-1_0.4.92-7_amd64.deb ; \
apt update && \
apt --fix-broken install -y && \
rm -rf /var/lib/apt/lists/* && \
apt-get clean && \
rm -f /usr/src/libappindicator3-1_0.4.92-7_amd64.deb
# install Chrome browser
RUN wget --no-verbose -O /usr/src/google-chrome-stable_current_amd64.deb "http://dl.google.com/linux/chrome/deb/pool/main/g/google-chrome-stable/google-chrome-stable_${CHROME_VERSION}-1_amd64.deb" && \
dpkg -i /usr/src/google-chrome-stable_current_amd64.deb ; \
apt update && \
apt --fix-broken install -y && \
rm -rf /var/lib/apt/lists/* && \
apt-get clean && \
rm -f /usr/src/google-chrome-stable_current_amd64.deb
# "fake" dbus address to prevent errors
# https://github.com/SeleniumHQ/docker-selenium/issues/87
ENV DBUS_SESSION_BUS_ADDRESS=/dev/null
# install Firefox browser
RUN wget --no-verbose -O /tmp/firefox.tar.bz2 "https://download-installer.cdn.mozilla.net/pub/firefox/releases/${FIREFOX_VERSION}/linux-x86_64/en-US/firefox-${FIREFOX_VERSION}.tar.bz2" && \
tar -C /opt -xjf /tmp/firefox.tar.bz2 && \
rm /tmp/firefox.tar.bz2 && \
ln -fs /opt/firefox/firefox /usr/bin/firefox
RUN echo "Downloading Latest Edge version..."
## Setup Edge
RUN curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg
RUN install -o root -g root -m 644 microsoft.gpg /etc/apt/trusted.gpg.d/
RUN sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/edge stable main" > /etc/apt/sources.list.d/microsoft-edge-dev.list'
RUN rm microsoft.gpg
## Install Edge
RUN apt-get update && \
apt-get install -y microsoft-edge-dev \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean
# Add a link to the browser that allows Cypress to find it
RUN ln -s /usr/bin/microsoft-edge /usr/bin/edge
# versions of local tools
RUN echo " node version: $(node -v) \n" \
"npm version: $(npm -v) \n" \
"yarn version: $(yarn -v) \n" \
"debian version: $(cat /etc/debian_version) \n" \
"Chrome version: $(google-chrome --version) \n" \
"Firefox version: $(firefox --version) \n" \
"Edge version: $(edge --version) \n" \
"git version: $(git --version) \n" \
"whoami: $(whoami) \n"
# a few environment variables to make NPM installs easier
# good colors for most applications
ENV TERM=xterm
# avoid million NPM install messages
ENV npm_config_loglevel=warn
# allow installing when the main user is root
ENV npm_config_unsafe_perm=true

View File

@@ -1,11 +0,0 @@
FROM node:14-alpine
RUN apk update && apk add git curl jq && mkdir -p /opt
COPY --chown=root:root wait-for.sh /opt/wait-for
RUN chmod +x /opt/wait-for && ln -s /opt/wait-for /usr/local/bin/wait-for
USER node
CMD []

View File

@@ -1,184 +0,0 @@
#!/bin/sh
# The MIT License (MIT)
#
# Copyright (c) 2017 Eficode Oy
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
set -- "$@" -- "$TIMEOUT" "$QUIET" "$PROTOCOL" "$HOST" "$PORT" "$result"
TIMEOUT=15
QUIET=0
# The protocol to make the request with, either "tcp" or "http"
PROTOCOL="tcp"
echoerr() {
if [ "$QUIET" -ne 1 ]; then printf "%s\n" "$*" 1>&2; fi
}
usage() {
exitcode="$1"
cat << USAGE >&2
Usage:
$0 host:port|url [-t timeout] [-- command args]
-q | --quiet Do not output any status messages
-t TIMEOUT | --timeout=timeout Timeout in seconds, zero for no timeout
-- COMMAND ARGS Execute command with args after the test finishes
USAGE
exit "$exitcode"
}
wait_for() {
case "$PROTOCOL" in
tcp)
if ! command -v nc >/dev/null; then
echoerr 'nc command is missing!'
exit 1
fi
;;
wget)
if ! command -v wget >/dev/null; then
echoerr 'wget command is missing!'
exit 1
fi
;;
esac
while :; do
case "$PROTOCOL" in
tcp)
nc -w 1 -z "$HOST" "$PORT" > /dev/null 2>&1
;;
http)
wget --timeout=1 -q "$HOST" -O /dev/null > /dev/null 2>&1
;;
*)
echoerr "Unknown protocol '$PROTOCOL'"
exit 1
;;
esac
result=$?
if [ $result -eq 0 ] ; then
if [ $# -gt 7 ] ; then
for result in $(seq $(($# - 7))); do
result=$1
shift
set -- "$@" "$result"
done
TIMEOUT=$2 QUIET=$3 PROTOCOL=$4 HOST=$5 PORT=$6 result=$7
shift 7
exec "$@"
fi
exit 0
fi
if [ "$TIMEOUT" -le 0 ]; then
break
fi
TIMEOUT=$((TIMEOUT - 1))
sleep 1
done
echo "Operation timed out" >&2
exit 1
}
while :; do
case "$1" in
http://*|https://*)
HOST="$1"
PROTOCOL="http"
shift 1
;;
*:* )
HOST=$(printf "%s\n" "$1"| cut -d : -f 1)
PORT=$(printf "%s\n" "$1"| cut -d : -f 2)
shift 1
;;
-q | --quiet)
QUIET=1
shift 1
;;
-q-*)
QUIET=0
echoerr "Unknown option: $1"
usage 1
;;
-q*)
QUIET=1
result=$1
shift 1
set -- -"${result#-q}" "$@"
;;
-t | --timeout)
TIMEOUT="$2"
shift 2
;;
-t*)
TIMEOUT="${1#-t}"
shift 1
;;
--timeout=*)
TIMEOUT="${1#*=}"
shift 1
;;
--)
shift
break
;;
--help)
usage 0
;;
-*)
QUIET=0
echoerr "Unknown option: $1"
usage 1
;;
*)
QUIET=0
echoerr "Unknown argument: $1"
usage 1
;;
esac
done
if ! [ "$TIMEOUT" -ge 0 ] 2>/dev/null; then
echoerr "Error: invalid timeout '$TIMEOUT'"
usage 3
fi
case "$PROTOCOL" in
tcp)
if [ "$HOST" = "" ] || [ "$PORT" = "" ]; then
echoerr "Error: you need to provide a host and port to test."
usage 2
fi
;;
http)
if [ "$HOST" = "" ]; then
echoerr "Error: you need to provide a host to test."
usage 2
fi
;;
esac
wait_for "$@"