diff --git a/.env b/.env new file mode 100644 index 0000000000000000000000000000000000000000..32b58de6b1c84352cbd8ce5a063a0c01b44e3abb --- /dev/null +++ b/.env @@ -0,0 +1,5 @@ +DOMAINNAME=${DOMAINNAME:-$(dnsdomainname)} +HOSTNAME=${HOSTNAME:-$(hostname)} +# TZ format: https://pubs.opengroup.org/onlinepubs/007904975/basedefs/xbd_chap08.html +TZ=CET-1CEST,M3.5.0,M10.5.0/3 + diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000000000000000000000000000000000000..91077515b515ef709fbbc81fcdf731b9b03e7cb0 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,98 @@ +variables: + DESCRIPTION: "COAST Recipes image" + IMAGE_NAME_COMMIT_REF: "$CI_REGISTRY_IMAGE/coast-recipes:$CI_COMMIT_REF_SLUG" + IMAGE_NAME_COMMIT_TAG: "$CI_REGISTRY_IMAGE/coast-recipes:$CI_COMMIT_TAG" + IMAGE_NAME_LATEST: "$CI_REGISTRY_IMAGE/coast-recipes:latest" + IMAGE_NAME_REMOTE: instituteforsoftware/coast-recipes + IMAGE_VENDOR: "IFS Institute For Software" + +stages: +- build +- test +- deploy + +default: + image: docker:latest + +Build: + stage: build + tags: + - docker + script: + - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY + - docker build --pull --no-cache + --label maintainer="$GITLAB_USER_EMAIL" + --label org.label-schema.build-date="$(date -u +"%Y-%m-%dT%H:%M:%SZ")" + --label org.label-schema.description="$DESCRIPTION" + --label org.label-schema.name="$CI_PROJECT_NAME" + --label org.label-schema.schema-version="1.0" + --label org.label-schema.url="$CI_PROJECT_URL" + --label org.label-schema.vcs-ref="$CI_COMMIT_SHA" + --label org.label-schema.vcs-url="$(echo $CI_REPOSITORY_URL | sed 's|gitlab-ci-token[^@]*@||')" + --label org.label-schema.vendor="${IMAGE_VENDOR:-$CI_PROJECT_NAMESPACE}" + --label org.label-schema.version="${CI_COMMIT_TAG:-$CI_COMMIT_REF_NAME}" + --tag=$IMAGE_NAME_COMMIT_REF + --file=Dockerfile + . + - docker push $IMAGE_NAME_COMMIT_REF + +Test: + stage: test + tags: + - docker + variables: + SERVICE_NAME: recipes_test_${CI_JOB_ID} + SERVICE_PORT_INTERN: 51200 + before_script: + - ( cd /tmp && wget https://gitlab.dev.ifs.hsr.ch/ifs/wait-for-it/raw/master/wait-for-it.sh && chmod +x wait-for-it.sh ) + script: + - docker run --detach --rm --name ${SERVICE_NAME} --hostname=${SERVICE_NAME} $IMAGE_NAME_COMMIT_REF + - service_ip=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' ${SERVICE_NAME}) + - /tmp/wait-for-it.sh --host=${service_ip} --port=${SERVICE_PORT_INTERN} --timeout=${WAIT_ON_SERVER_TIME:-30} --strict -- sh -c "wget --server-response --quiet -O /dev/null http://${service_ip}:${SERVICE_PORT_INTERN}"; + after_script: + - docker logs --timestamps --details --tail=100 ${SERVICE_NAME} || true; + - docker container stop --time 1 ${SERVICE_NAME} || true + +Tag: + stage: deploy + only: + - tags + tags: + - docker + script: + - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY + - docker pull $IMAGE_NAME_COMMIT_REF + - docker image tag $IMAGE_NAME_COMMIT_REF $IMAGE_NAME_COMMIT_TAG + - docker push $IMAGE_NAME_COMMIT_TAG + - test -n "$DOCKER_USER" -a -n "$IMAGE_NAME_REMOTE" && { + docker login -u "$DOCKER_USER" -p "$DOCKER_PASS"; + docker tag $IMAGE_NAME_COMMIT_REF $IMAGE_NAME_REMOTE:$CI_COMMIT_TAG; + docker push $IMAGE_NAME_REMOTE:$CI_COMMIT_TAG; + } || true + - test -n "$MICROBADGER_UPDATE_HOOK" && { + wget --post-data "" $MICROBADGER_UPDATE_HOOK; + } || true + +Deploy latest image: + stage: deploy + only: + - tags + when: manual + tags: + - docker + script: + - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY + - docker pull $IMAGE_NAME_COMMIT_REF + - docker image tag $IMAGE_NAME_COMMIT_REF $IMAGE_NAME_LATEST + - docker push $IMAGE_NAME_LATEST + - test -n "$DOCKER_USER" -a -n "$IMAGE_NAME_REMOTE" && { + docker login -u "$DOCKER_USER" -p "$DOCKER_PASS"; + docker tag $IMAGE_NAME_COMMIT_REF $IMAGE_NAME_REMOTE:latest; + docker push $IMAGE_NAME_REMOTE:latest; + } || true + - test -n "$MICROBADGER_UPDATE_HOOK" && { + wget --post-data "" $MICROBADGER_UPDATE_HOOK; + } || true + - test -n "$TRIGGER_URL" && { + wget --post-data "token=$TRIGGER_TOKEN&ref=master" $TRIGGER_URL; + } || true diff --git a/.project b/.project new file mode 100644 index 0000000000000000000000000000000000000000..eaaec3ccfbad5ef560f95caa248cf1588e23d676 --- /dev/null +++ b/.project @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>docker-coast-recipes</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + </buildSpec> + <natures> + </natures> +</projectDescription> diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc new file mode 100644 index 0000000000000000000000000000000000000000..b7225f29b6319b4ca0e96cc3447741ffd6c8a761 --- /dev/null +++ b/CHANGELOG.adoc @@ -0,0 +1,112 @@ += Changelog + +== tag: 0.9.0 +* Bumped version to 0.9.0 (810e01d) + + +* based image on a multi compiler ubuntu image, added gitlab ci (c7d8d02) + + +* adjusted image vendor to IFS (431e518) + + +* added job id as suffix for service name (be32838) + + +* changed method to test locally started recipes server (7d4590a) + + +* do http level testing only (e0d3814) + + +* log containers and address (0244a65) + + +* don't use dind service (10e89a6) + + +* don't change build directory in before_script (a6826bd) + + +* removed local copies of wait-foor scripts (d663da1) + + +* use ash because bash is not available (3fd2775) + + +* scripts executable bit set (4141590) + + +* using wait-for-it to wait on recipes server (cebfffa) + + +* show log timestamps (8ced189) + + +* added missing semicolon (1a95cd3) + + +* added missing publish port arguments (a1b6988) + + +* increased timeout for test and added hostname (73b416c) + + +* stop running container also in case of errors (606bcab) + + +* added changelog (c99a666) + + +* reverted extensive debug logging (a056a3c) + + +* find out what's wrong with ci building (ca8b8e8) + + +* added sample docker-compose file to start recipes (56f4417) + + +* execute bash commands in non interactive mode (8463862) + + +* wait on recipes server to become available (03967fc) + + +* use recipes wait timeout from envvar if available (6b3d6be) + + +* extended test step to be more verbose (3f8cca7) + + +* gitlab ci build file added (c3459c5) + + +* DRY: use coast-build image as base (c817eb1) + + +* cloning coast repos fixed (cffb1be) + + +* added missing lib32-zlib (9674d85) + + +* removed certificate tweaks as we now have valid ssl certs (9bc14d1) + + +* replacing pip.conf placeholder with correct user name (399aecb) + + +* reflecting base image changes regarding removed UIG/GID variables (77cbe08) + + +* removed interactive option from bash commands (131521c) + + +* not checking signatures for ib fonts (9ff0548) + + +* not updating installed packages before installing new ones (e9dbe15) + + +* Initial setup for a Coast Recipes image (0b77cf5) diff --git a/Dockerfile b/Dockerfile index 0f9e2ccddc044e749c3ed7e11f3e3f860ebf3a2e..3c8e4703300fe911840568254e1e241359171d86 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,46 +1,21 @@ -FROM marcelhuberfoo/arch +FROM instituteforsoftware/coast-build:latest -MAINTAINER Marcel Huber <marcelhuberfoo@gmail.com> +USER $USERNAME -USER root +RUN git clone --branch feature/FixCompilation https://gitlab.dev.ifs.hsr.ch/ifs/coast.git $SOURCEDIR/coast +WORKDIR $SOURCEDIR/coast +RUN git clone --branch master https://gerrit.coast-project.org/p/boost.git 3rdparty/boost +RUN git clone --branch master https://gerrit.coast-project.org/p/openssl.git 3rdparty/openssl +RUN git clone --branch master https://gitlab.dev.ifs.hsr.ch/ifs/wdscripts.git +RUN git clone --branch master https://gerrit.coast-project.org/p/recipes.git -RUN echo -e '[infinality-bundle]\nSigLevel=Never\nServer = http://bohoomil.com/repo/$arch\n[infinality-bundle-fonts]\nSigLevel=Never\nServer = http://bohoomil.com/repo/fonts' >> /etc/pacman.conf -RUN pacman -Syy && \ - printf "\\ny\\ny\\n" | pacman -S multilib-devel && \ - printf "y\\ny\\n" | pacman -Scc -RUN pacman -S --noconfirm --quiet --noprogressbar --needed python2 git lib32-openssl lib32-zlib gdb doxygen graphviz \ - fontconfig-infinality-ultimate ibfonts-meta-base && \ - printf "y\\ny\\n" | pacman -Scc -RUN rm -f /var/lib/pacman/sync/*.db +RUN bash -c "pip install --upgrade -r $SOURCEDIR/coast/requires.txt" -ADD entrypoint.sh / -ADD pip.conf /$UNAME/.pip/ -RUN sed -i "s|USER|$UNAME|" /$UNAME/.pip/pip.conf -RUN chown -R $UNAME:$GNAME /$UNAME/ +ENV SCONSFLAGS="--enable-Trace --baseoutdir=$BUILDOUTPUTDIR/coast-build/ --with-src-boost=3rdparty/boost --with-bin-openssl=3rdparty/openssl" -USER $UNAME -ENV VENVDIR=/$UNAME/.venv27scons -RUN echo "[[ -d \"\$VENVDIR\" ]] && . $VENVDIR/bin/activate" >> $HOME/.bashrc - -RUN cd $HOME && git clone --single-branch --branch master --depth 1 https://github.com/pypa/virtualenv.git -RUN python2 $HOME/virtualenv/virtualenv.py $VENVDIR -RUN cd $HOME && git clone --single-branch --branch master --depth 1 https://gerrit.coast-project.org/p/coast.git -RUN cd $HOME/coast && \ - git clone --single-branch --branch master --depth 1 https://gerrit.coast-project.org/p/boost.git 3rdparty/boost &&\ - git clone --single-branch --branch master --depth 1 https://gerrit.coast-project.org/p/wdscripts.git && \ - git clone --single-branch --branch master --depth 1 https://gerrit.coast-project.org/p/recipes.git - -RUN bash -l -c 'pip install -U -r $HOME/coast/requires.txt' - -RUN bash -l -c 'cd $HOME/coast && \ - scons -u --jobs=$(nproc) --with-src-boost=3rdparty/boost --ignore-missing --doxygen-only && \ - scons -u --jobs=$(nproc) CoastRecipes --with-src-boost=3rdparty/boost && \ - cd apps/CoastRecipes && ln -s ../../doc/Coast/html COASTDoc' - -USER root +RUN bash -c "scons -u --jobs=$(nproc) CoastRecipes" +RUN bash -c "scons -u --ignore-missing --doxygen-only && \ + ln -sf $BUILDOUTPUTDIR/coast-build/doc/Coast/html $BUILDOUTPUTDIR/coast-build/apps/CoastRecipes/COASTDoc" EXPOSE 51200 51201 - -ENTRYPOINT ["/entrypoint.sh"] -CMD ["dummy"] - +CMD bash -c "scons -u --jobs=$(nproc) CoastRecipes --run-force" diff --git a/VERSION b/VERSION new file mode 100644 index 0000000000000000000000000000000000000000..899f24fc754a14b89617093824d258aaa3aa2943 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +0.9.0 \ No newline at end of file diff --git a/crane.yaml b/crane.yaml deleted file mode 100644 index 4a61d1bb0376b9d9183db7d810e5e6182e078ef5..0000000000000000000000000000000000000000 --- a/crane.yaml +++ /dev/null @@ -1,24 +0,0 @@ -groups: - default: - - recipes -containers: - recipes: &cref - build: - context: . - file: Dockerfile - image: marcelhuberfoo/docker-coast-recipes - run: &crefrun - detach: false -# env: - stop-signal: SIGINT -# volume: - publish: - - "51200:51200" - - "51201:51201" - interactive: true - tty: true - exec: - interactive: true - tty: true - cshell: { <<: *cref, run: { <<: *crefrun, detach, entrypoint: /bin/bash, tty: true, interactive: true } } -volumes: diff --git a/entrypoint.sh b/entrypoint.sh deleted file mode 100755 index 072b97470c70bcfba4f9da95db2ad5cd79b3e952..0000000000000000000000000000000000000000 --- a/entrypoint.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh -set -e -umask 002 - -if [ "$1" = 'dummy' ]; then - exec gosu $UNAME bash -l -c 'cd $HOME/coast && scons -u --jobs=$(nproc) CoastRecipes --with-src-boost=3rdparty/boost --run' -fi -exec "$@" diff --git a/pip.conf b/pip.conf deleted file mode 100644 index c758395ca414ce5b524f66421693a18a8008c070..0000000000000000000000000000000000000000 --- a/pip.conf +++ /dev/null @@ -1,2 +0,0 @@ -[global] -index-url=https://devpi.coast-project.org/coast/CoastSconsider/+simple diff --git a/recipes-stack.yml b/recipes-stack.yml new file mode 100644 index 0000000000000000000000000000000000000000..61edaf28951d91d82943c407617f2cccdb493112 --- /dev/null +++ b/recipes-stack.yml @@ -0,0 +1,43 @@ +networks: + web: + attachable: true + driver: overlay + external: true + name: web +services: + recipes: + deploy: + labels: + traefik.docker.network: web + traefik.enable: "True" + traefik.nonssl.frontend.entrypoints: http + traefik.nonssl.frontend.headers.SSLRedirect: "False" + traefik.nonssl.frontend.redirect.entryPoint: http + traefik.nonssl.frontend.rule: Host:recipes.docker.localhost + traefik.nonssl.port: '51200' + traefik.nonssl.protocol: http + mode: replicated + replicas: 0 + restart_policy: + condition: on-failure + delay: 10s + max_attempts: 10 + window: 300s + environment: + TZ: CET-1CEST,M3.5.0,M10.5.0/3 + hostname: '{{.Service.Name}}' + image: instituteforsoftware/coast-recipes + networks: + web: null + ports: + - mode: host + protocol: tcp + published: 51200 + target: 51200 + - mode: host + protocol: tcp + published: 51201 + target: 51201 + stop_signal: SIGINT +version: '3.7' + diff --git a/recipes-stack.yml.tmpl b/recipes-stack.yml.tmpl new file mode 100644 index 0000000000000000000000000000000000000000..9c61ac606ed867194d3ec91f8868e0c6a7e3c695 --- /dev/null +++ b/recipes-stack.yml.tmpl @@ -0,0 +1,61 @@ +#configs: +# wait-for-it: +# external: true +# name: wait-for-it.sh.v1.0.0 + +networks: + web: + attachable: true + driver: overlay + external: true + name: web + +services: + recipes: + deploy: + labels: + traefik.docker.network: web + traefik.enable: "True" + traefik.nonssl.frontend.entrypoints: http + traefik.nonssl.frontend.headers.SSLRedirect: false + traefik.nonssl.frontend.redirect.entryPoint: http + traefik.nonssl.frontend.rule: Host:$RECIPES_FQDN + traefik.nonssl.port: $RECIPES_PORT + traefik.nonssl.protocol: http +# traefik.ssl.frontend.entrypoints: http +# traefik.ssl.frontend.headers.SSLRedirect: false +# traefik.ssl.frontend.redirect.entryPoint: http +# traefik.ssl.frontend.rule: Host:$RECIPES_FQDN +# traefik.ssl.port: $RECIPES_PORT_SSL +# traefik.ssl.protocol: http + mode: replicated + replicas: 0 + restart_policy: + condition: on-failure + delay: 10s + max_attempts: 10 + window: 300s + environment: + # https://github.com/jwilder/nginx-proxy#how-ssl-support-works +# HTTPS_METHOD: nohttps + TZ: $TZ + hostname: '{{.Service.Name}}' + image: instituteforsoftware/coast-recipes + networks: + web: null +# not needed in case we're behind traefik + ports: + - mode: host + protocol: tcp + published: 51200 + target: 51200 + - mode: host + protocol: tcp + published: 51201 + target: 51201 + stop_signal: SIGINT + +version: '3.7' + +#volumes: +# service-vol: {} diff --git a/recipes.env b/recipes.env new file mode 100644 index 0000000000000000000000000000000000000000..85891b8a78a53375c287b1e37efe3e65547b0317 --- /dev/null +++ b/recipes.env @@ -0,0 +1,3 @@ +RECIPES_FQDN=recipes.$DOMAINNAME +RECIPES_PORT=51200 +RECIPES_PORT_SSL=51201