From 1772bccdc2b327921a91e442b2bcf6f9fd510672 Mon Sep 17 00:00:00 2001 From: unteem Date: Fri, 4 Feb 2022 12:37:51 +0100 Subject: [PATCH 01/12] use upstream image --- Dockerfile | 94 ++++++++---------------------------------------------- 1 file changed, 14 insertions(+), 80 deletions(-) diff --git a/Dockerfile b/Dockerfile index 494f4b8..6281974 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,98 +1,32 @@ -FROM ruby:2.7.5 +ARG from=discourse/base +ARG tag=release -ARG DISCOURSE_VERSION +FROM $from:$tag ENV RAILS_ENV=production \ - DEBIAN_VERSION=bullseye \ - DISCOURSE_DB_HOST=postgres \ - DISCOURSE_REDIS_HOST=redis \ DISCOURSE_SERVE_STATIC_ASSETS=true \ - DISCOURSE_VERSION=${DISCOURSE_VERSION} \ EMBER_CLI_PROD_ASSETS=1 \ - JEMALLOC_NEW=3.6.0 \ - JEMALLOC_STABLE=5.2.1 \ - PG_MAJOR=13 \ - NODE_MAJOR=16 \ RUBY_GLOBAL_METHOD_CACHE_SIZE=131072 \ RUBY_GC_HEAP_GROWTH_MAX_SLOTS=40000 \ RUBY_GC_HEAP_INIT_SLOTS=400000 \ RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR=1.5 \ - RUBY_GC_MALLOC_LIMIT=90000000 \ - BUILD_DEPS="\ - autoconf \ - advancecomp \ - libbz2-dev \ - libfreetype6-dev \ - libjpeg-dev \ - libjpeg-turbo-progs \ - libtiff-dev \ - pkg-config" + RUBY_GC_MALLOC_LIMIT=90000000 + +# temp/ owned by root, also app/assets/plugins and maybe others ? +RUN chown -R discourse:discourse /var/www/discourse + +# jq needed to create kubernetes CM +RUN apt-get update && apt-get install -y jq COPY install /tmp/install -RUN ls /tmp/ && ls /tmp/install +WORKDIR /var/www/discourse -RUN curl http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc | apt-key add - \ - && echo "deb http://apt.postgresql.org/pub/repos/apt/ ${DEBIAN_VERSION}-pgdg main" | \ - tee /etc/apt/sources.list.d/postgres.list \ - && curl --silent --location https://deb.nodesource.com/setup_${NODE_MAJOR}.x | bash - \ - && apt-get update && apt-get install -y --no-install-recommends \ - ${BUILD_DEPS} \ - ca-certificates \ - brotli \ - ghostscript \ - gsfonts \ - jpegoptim \ - liblqr-1-0 \ - libxml2 \ - nodejs \ - optipng \ - jhead \ - pngcrush \ - pngquant \ - postgresql-client-${PG_MAJOR} \ - postgresql-contrib-${PG_MAJOR} libpq-dev libreadline-dev \ - && npm install svgo uglify-js -g \ - && mkdir /jemalloc-stable && cd /jemalloc-stable &&\ - wget https://github.com/jemalloc/jemalloc/releases/download/${JEMALLOC_STABLE}/jemalloc-${JEMALLOC_STABLE}.tar.bz2 &&\ - tar -xjf jemalloc-${JEMALLOC_STABLE}.tar.bz2 && cd jemalloc-${JEMALLOC_STABLE} && ./configure --prefix=/usr && make && make install &&\ - cd / && rm -rf /jemalloc-stable \ - && mkdir /jemalloc-new && cd /jemalloc-new &&\ - wget https://github.com/jemalloc/jemalloc/releases/download/${JEMALLOC_NEW}/jemalloc-${JEMALLOC_NEW}.tar.bz2 &&\ - tar -xjf jemalloc-${JEMALLOC_NEW}.tar.bz2 && cd jemalloc-${JEMALLOC_NEW} && ./configure --prefix=/usr --with-install-suffix=${JEMALLOC_NEW} && make build_lib && make install_lib &&\ - cd / && rm -rf /jemalloc-new \ - && gem update --system \ - && gem install bundler --force \ - && rm -rf /usr/local/share/ri/${RUBY_VERSION}/system \ - && /tmp/install/imagemagick \ - # Validate install - && ruby -Eutf-8 -e "v = \`convert -version\`; %w{png tiff jpeg freetype}.each { |f| unless v.include?(f); STDERR.puts('no ' + f + ' support in imagemagick'); exit(-1); end }" \ - && addgroup --gid 1000 discourse \ - && adduser --system --uid 1000 --ingroup discourse --shell /bin/bash discourse \ - && cd /home/discourse \ - && mkdir -p tmp/pids \ - && mkdir -p ./tmp/sockets \ - && git clone --branch ${DISCOURSE_VERSION} https://github.com/discourse/discourse.git \ - && chown -R discourse:discourse . \ - && cd /home/discourse/discourse \ - && git remote set-branches --add origin tests-passed \ - && sed -i 's/daemonize true/daemonize false/g' ./config/puma.rb \ - && sed -i "s/msgpack (1.4.1)/msgpack (1.4.2)/" Gemfile.lock \ - && bundle config build.nokogiri --use-system-libraries \ - && bundle install --deployment --verbose --without test --without development --retry 3 --jobs 4 \ - && find /home/discourse/discourse/vendor/bundle -name tmp -type d -exec rm -rf {} + \ - #&& apt-get remove -y --purge ${BUILD_DEPS} \ - #&& apt-get autoremove -y \ - && rm -rf /var/lib/apt/lists/* +USER discourse -RUN cd /home/discourse/discourse/plugins \ +RUN cd /var/www/discourse/plugins \ && for plugin in $(cat /tmp/install/plugin-list); do \ git clone $plugin; \ - done \ - && chown -R discourse:discourse . - -WORKDIR /home/discourse/discourse - -USER discourse + done CMD ["bundle", "exec", "rails", "server", "-b", "0.0.0.0"] -- GitLab From 3a030b7f6b20b658a0170da01a63b35b1366a977 Mon Sep 17 00:00:00 2001 From: unteem Date: Fri, 4 Feb 2022 12:39:06 +0100 Subject: [PATCH 02/12] remove imagemagick install script --- install/imagemagick | 62 --------------------------------------------- 1 file changed, 62 deletions(-) delete mode 100755 install/imagemagick diff --git a/install/imagemagick b/install/imagemagick deleted file mode 100755 index 023f09a..0000000 --- a/install/imagemagick +++ /dev/null @@ -1,62 +0,0 @@ -#!/bin/bash -set -e - -# version check: https://github.com/ImageMagick/ImageMagick/releases -IMAGE_MAGICK_VERSION="7.0.10-24" -IMAGE_MAGICK_HASH="c555b4724127f9993500c9a7bab148e6075a7397957516b9e0dd9faa02d5c98e" - -# version check: https://libpng.sourceforge.io/index.html -LIBPNG_VERSION="1.6.37" -LIBPNG_HASH="daeb2620d829575513e35fecc83f0d3791a620b9b93d800b763542ece9390fb4" - -PREFIX=/usr/local -WDIR=/tmp/imagemagick - -# Install build deps -apt -y -q remove imagemagick - -mkdir -p $WDIR -cd $WDIR - -# Build and install libpng -wget -O $WDIR/libpng.tar.gz https://prdownloads.sourceforge.net/libpng/libpng-$LIBPNG_VERSION.tar.gz?download -sha256sum $WDIR/libpng.tar.gz -echo "$LIBPNG_HASH $WDIR/libpng.tar.gz" | sha256sum -c - -tar -xzvf $WDIR/libpng.tar.gz -cd $WDIR/libpng-$LIBPNG_VERSION - -./configure --prefix=$PREFIX -make all && make install - -# Build and install ImageMagick -wget -O $WDIR/ImageMagick.tar.gz "https://github.com/ImageMagick/ImageMagick/archive/$IMAGE_MAGICK_VERSION.tar.gz" -sha256sum $WDIR/ImageMagick.tar.gz -echo "$IMAGE_MAGICK_HASH $WDIR/ImageMagick.tar.gz" | sha256sum -c -IMDIR=$WDIR/$(tar tzf $WDIR/ImageMagick.tar.gz --wildcards "ImageMagick-*/configure" |cut -d/ -f1) -tar zxf $WDIR/ImageMagick.tar.gz -C $WDIR -cd $IMDIR -PKG_CONF_LIBDIR=$PREFIX/lib LDFLAGS=-L$PREFIX/lib CFLAGS=-I$PREFIX/include ./configure \ - --prefix=$PREFIX \ - --enable-static \ - --enable-bounds-checking \ - --enable-hdri \ - --enable-hugepages \ - --with-threads \ - --with-modules \ - --with-quantum-depth=16 \ - --without-magick-plus-plus \ - --with-bzlib \ - --with-zlib \ - --without-autotrace \ - --with-freetype \ - --with-jpeg \ - --without-lcms \ - --with-lzma \ - --with-png \ - --with-tiff -make all && make install - -cd $HOME -rm -rf $WDIR -ldconfig /usr/local/lib -- GitLab From 7fa1141a2b5adaca2f00095bfd697c32e924c933 Mon Sep 17 00:00:00 2001 From: unteem Date: Fri, 4 Feb 2022 14:05:06 +0100 Subject: [PATCH 03/12] update readme --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 983e9c1..b81641d 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,8 @@ # docker-discourse -discourse image for discourse service +Discourse image for discourse service +It is based on [upstream discourse image](https://hub.docker.com/r/discourse/base/) ## Discourse plugins -This image supports installing Discourse plugins at build time, via the `DISCOURSE_ADDITIONAL_PLUGINS` [build arg](https://docs.docker.com/engine/reference/builder/#/arg). Set it to a whitespace (space, tab, newline) separated list if valid `git` URLs of plugins to be installed at build time. \ No newline at end of file +This image supports installing Discourse plugins at build time, via the `install/plugin-list` file. It lists`git` URLs of plugins to be installed at build time. \ No newline at end of file -- GitLab From 143f32f949119ec2132eeae57efeb9f5ad1d5ddf Mon Sep 17 00:00:00 2001 From: unteem Date: Fri, 4 Feb 2022 14:06:14 +0100 Subject: [PATCH 04/12] update gitlab-ci --- .gitlab-ci.yml | 42 ++++++------------------------------------ 1 file changed, 6 insertions(+), 36 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 956af63..981844c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,47 +1,18 @@ variables: GIT_SUBMODULE_STRATEGY: recursive DOCKER_HUB_REPO: libresh/discourse - -test-beta: - tags: - - build - image: - name: gcr.io/kaniko-project/executor:debug - entrypoint: [""] - script: - - export DISCOURSE_VERSION=`wget -qO- https://api.github.com/repos/discourse/discourse/tags | grep name | cut -d'"' -f4 | grep beta | head -n1` - - /kaniko/executor --context . --no-push --build-arg DISCOURSE_VERSION=$DISCOURSE_VERSION - except: - - master - -test-stable: +test: tags: - build image: name: gcr.io/kaniko-project/executor:debug entrypoint: [""] script: - - export DISCOURSE_VERSION=`wget -qO- https://api.github.com/repos/discourse/discourse/tags | grep name | cut -d'"' -f4 | grep -v beta | head -n1` - - /kaniko/executor --context . --no-push --build-arg DISCOURSE_VERSION=$DISCOURSE_VERSION + - /kaniko/executor --context . --no-push except: - master -build-beta: - tags: - - build - image: - name: gcr.io/kaniko-project/executor:debug - entrypoint: [""] - script: - - cp $DOCKER_SECRET_CONFIG /kaniko/.docker/config.json - - export DISCOURSE_VERSION=`wget -qO- https://api.github.com/repos/discourse/discourse/tags | grep name | cut -d'"' -f4 | grep beta | head -n1` - - export DISCOURSE_MAJOR=`echo $DISCOURSE_VERSION | cut -d"." -f1-3` - - export DESTINATION="--destination ${DOCKER_HUB_REPO}:${DISCOURSE_VERSION} --destination ${DOCKER_HUB_REPO}:${DISCOURSE_MAJOR} --destination ${DOCKER_HUB_REPO}:beta" - - /kaniko/executor --context . ${DESTINATION} --build-arg DISCOURSE_VERSION=$DISCOURSE_VERSION - only: - - master - -build-stable: +build: tags: - build image: @@ -49,9 +20,8 @@ build-stable: entrypoint: [""] script: - cp $DOCKER_SECRET_CONFIG /kaniko/.docker/config.json - - export DISCOURSE_VERSION=`wget -qO- https://api.github.com/repos/discourse/discourse/tags | grep name | cut -d'"' -f4 | grep -v beta | head -n1` - - export DISCOURSE_MAJOR=`echo $DISCOURSE_VERSION | cut -d"." -f1-2` - - export DESTINATION="--destination ${DOCKER_HUB_REPO}:${DISCOURSE_VERSION} --destination ${DOCKER_HUB_REPO}:${DISCOURSE_MAJOR} --destination ${DOCKER_HUB_REPO}:stable" - - /kaniko/executor --context . ${DESTINATION} --build-arg DISCOURSE_VERSION=$DISCOURSE_VERSION + - export TAG=`date +%Y-%m-%d-%H%M` + - export DESTINATION="--destination ${DOCKER_HUB_REPO}:${TAG} --destination ${DOCKER_HUB_REPO}:release" + - /kaniko/executor --context . ${DESTINATION} only: - master -- GitLab From 9d01abb3c81f4cd791fba37ef2627032514a283b Mon Sep 17 00:00:00 2001 From: Timothee Gosselin Date: Fri, 4 Feb 2022 13:24:18 +0000 Subject: [PATCH 05/12] use latest tag --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 981844c..f3832e1 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -21,7 +21,7 @@ build: script: - cp $DOCKER_SECRET_CONFIG /kaniko/.docker/config.json - export TAG=`date +%Y-%m-%d-%H%M` - - export DESTINATION="--destination ${DOCKER_HUB_REPO}:${TAG} --destination ${DOCKER_HUB_REPO}:release" + - export DESTINATION="--destination ${DOCKER_HUB_REPO}:${TAG} --destination ${DOCKER_HUB_REPO}:latest" - /kaniko/executor --context . ${DESTINATION} only: - master -- GitLab From 95b05b09e45fbf74ec3550bf201751dd7918b5c0 Mon Sep 17 00:00:00 2001 From: unteem Date: Mon, 7 Feb 2022 11:02:30 +0100 Subject: [PATCH 06/12] versioned build --- .gitlab-ci.yml | 58 +++++++++++++++++++++++++++++++++++++------------- Dockerfile | 21 +++++++++++++----- 2 files changed, 59 insertions(+), 20 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f3832e1..a9d8275 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,27 +1,55 @@ variables: GIT_SUBMODULE_STRATEGY: recursive DOCKER_HUB_REPO: libresh/discourse -test: - tags: - - build + +.test: image: name: gcr.io/kaniko-project/executor:debug entrypoint: [""] + variables: + DESTINATION: "--no-push" script: - - /kaniko/executor --context . --no-push + - cp $DOCKER_SECRET_CONFIG /kaniko/.docker/config.json + - export DISCOURSE_MAJOR=`echo $DISCOURSE_VERSION | cut -d"." -f1-3` + - export DESTINATION="--destination ${DOCKER_HUB_REPO}:${DISCOURSE_VERSION}-${DATE_TAG} --destination ${DOCKER_HUB_REPO}:${DISCOURSE_VERSION} --destination ${DOCKER_HUB_REPO}:${DISCOURSE_MAJOR} --destination ${DOCKER_HUB_REPO}:beta" + - /kaniko/executor --context . ${DESTINATION} --build-arg DISCOURSE_VERSION=$DISCOURSE_VERSION + - /kaniko/executor --context . --no-push --build-arg DISCOURSE_VERSION=$DISCOURSE_VERSION except: - master -build: - tags: - - build - image: - name: gcr.io/kaniko-project/executor:debug - entrypoint: [""] - script: - - cp $DOCKER_SECRET_CONFIG /kaniko/.docker/config.json - - export TAG=`date +%Y-%m-%d-%H%M` - - export DESTINATION="--destination ${DOCKER_HUB_REPO}:${TAG} --destination ${DOCKER_HUB_REPO}:latest" - - /kaniko/executor --context . ${DESTINATION} + test-beta: + extends: .test + variables: + CHANNEL: "beta" + before_script: + - export DISCOURSE_VERSION=`wget -qO- https://api.github.com/repos/discourse/discourse/tags | grep name | cut -d'"' -f4 | grep beta | head -n1` + +test-stable: + extends: .test + variables: + CHANNEL: "stable" + before_script: + - export DISCOURSE_VERSION=`wget -qO- https://api.github.com/repos/discourse/discourse/tags | grep name | cut -d'"' -f4 | grep -v beta | head -n1` + +.push: + extends: .test + before_script: + - export DATE=`date +%Y-%m-%d-%H%M` + - export DESTINATION="--destination ${DOCKER_HUB_REPO}:${DISCOURSE_VERSION}-${DATE} --destination ${DOCKER_HUB_REPO}:${DISCOURSE_VERSION} --destination ${DOCKER_HUB_REPO}:${DISCOURSE_MAJOR} --destination ${DOCKER_HUB_REPO}:${CHANEL}" + except: [] only: - master + +push-beta: + extends: .push + variables: + CHANNEL: "beta" + before_script: + - export DISCOURSE_VERSION=`wget -qO- https://api.github.com/repos/discourse/discourse/tags | grep name | cut -d'"' -f4 | grep beta | head -n1` + +push-stable: + extends: .push + variables: + CHANNEL: "stable" + before_script: + - export DISCOURSE_VERSION=`wget -qO- https://api.github.com/repos/discourse/discourse/tags | grep name | cut -d'"' -f4 | grep -v beta | head -n1` diff --git a/Dockerfile b/Dockerfile index 6281974..2f7e629 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,6 @@ ARG from=discourse/base -ARG tag=release +ARG tag=slim +ARG DISCOURSE_VERSION=test-passed FROM $from:$tag @@ -12,16 +13,26 @@ ENV RAILS_ENV=production \ RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR=1.5 \ RUBY_GC_MALLOC_LIMIT=90000000 -# temp/ owned by root, also app/assets/plugins and maybe others ? -RUN chown -R discourse:discourse /var/www/discourse # jq needed to create kubernetes CM RUN apt-get update && apt-get install -y jq -COPY install /tmp/install - WORKDIR /var/www/discourse +RUN git remote set-branches --add origin ${DISCOURSE_VERSION} &&\ + git fetch --depth 1 origin ${DISCOURSE_VERSION} &&\ + sudo -u discourse bundle config --local deployment true &&\ + sudo -u discourse bundle config --local path ./vendor/bundle &&\ + sudo -u discourse bundle config --local without test development &&\ + sudo -u discourse bundle install --jobs 4 &&\ + sudo -u discourse yarn install --production &&\ + sudo -u discourse yarn cache clean &&\ + bundle exec rake maxminddb:get &&\ + find /var/www/discourse/vendor/bundle -name tmp -type d -exec rm -rf {} + &&\ + chown -R discourse:discourse /var/www/discourse + +COPY install /tmp/install + USER discourse RUN cd /var/www/discourse/plugins \ -- GitLab From 0e8a55713af87c5fab365aa577ff07f857064dbb Mon Sep 17 00:00:00 2001 From: unteem Date: Mon, 7 Feb 2022 11:10:35 +0100 Subject: [PATCH 07/12] typo --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a9d8275..83b49bd 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -35,7 +35,7 @@ test-stable: extends: .test before_script: - export DATE=`date +%Y-%m-%d-%H%M` - - export DESTINATION="--destination ${DOCKER_HUB_REPO}:${DISCOURSE_VERSION}-${DATE} --destination ${DOCKER_HUB_REPO}:${DISCOURSE_VERSION} --destination ${DOCKER_HUB_REPO}:${DISCOURSE_MAJOR} --destination ${DOCKER_HUB_REPO}:${CHANEL}" + - export DESTINATION="--destination ${DOCKER_HUB_REPO}:${DISCOURSE_VERSION}-${DATE} --destination ${DOCKER_HUB_REPO}:${DISCOURSE_VERSION} --destination ${DOCKER_HUB_REPO}:${DISCOURSE_MAJOR} --destination ${DOCKER_HUB_REPO}:${CHANNEL}" except: [] only: - master -- GitLab From 232d2eb412a5bf3814ecdd09abb7bdb6d44b2180 Mon Sep 17 00:00:00 2001 From: unteem Date: Mon, 7 Feb 2022 11:11:10 +0100 Subject: [PATCH 08/12] fix indention --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 83b49bd..4ee7dd8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -17,7 +17,7 @@ variables: except: - master - test-beta: +test-beta: extends: .test variables: CHANNEL: "beta" -- GitLab From 051d2f3bd0167416fb98aa576cefa3b284b0aefd Mon Sep 17 00:00:00 2001 From: unteem Date: Mon, 7 Feb 2022 12:48:23 +0100 Subject: [PATCH 09/12] fix & refactore gitlab-ci --- .gitlab-ci.yml | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4ee7dd8..06c6189 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -2,6 +2,15 @@ variables: GIT_SUBMODULE_STRATEGY: recursive DOCKER_HUB_REPO: libresh/discourse +.compute_version: &compute_version + - | + if [ "$CHANNEL" == "stable" ]; then + FILTER="grep -v beta" + else + FILTER="grep beta" fi + - export DISCOURSE_VERSION=`wget -qO- https://api.github.com/repos/discourse/discourse/tags | grep name | cut -d'"' -f4 | $FILTER | head -n1` + + .test: image: name: gcr.io/kaniko-project/executor:debug @@ -9,11 +18,10 @@ variables: variables: DESTINATION: "--no-push" script: - - cp $DOCKER_SECRET_CONFIG /kaniko/.docker/config.json + - *compute_long_version - export DISCOURSE_MAJOR=`echo $DISCOURSE_VERSION | cut -d"." -f1-3` - export DESTINATION="--destination ${DOCKER_HUB_REPO}:${DISCOURSE_VERSION}-${DATE_TAG} --destination ${DOCKER_HUB_REPO}:${DISCOURSE_VERSION} --destination ${DOCKER_HUB_REPO}:${DISCOURSE_MAJOR} --destination ${DOCKER_HUB_REPO}:beta" - /kaniko/executor --context . ${DESTINATION} --build-arg DISCOURSE_VERSION=$DISCOURSE_VERSION - - /kaniko/executor --context . --no-push --build-arg DISCOURSE_VERSION=$DISCOURSE_VERSION except: - master @@ -21,19 +29,16 @@ test-beta: extends: .test variables: CHANNEL: "beta" - before_script: - - export DISCOURSE_VERSION=`wget -qO- https://api.github.com/repos/discourse/discourse/tags | grep name | cut -d'"' -f4 | grep beta | head -n1` test-stable: extends: .test variables: CHANNEL: "stable" - before_script: - - export DISCOURSE_VERSION=`wget -qO- https://api.github.com/repos/discourse/discourse/tags | grep name | cut -d'"' -f4 | grep -v beta | head -n1` .push: extends: .test before_script: + - cp $DOCKER_SECRET_CONFIG /kaniko/.docker/config.json - export DATE=`date +%Y-%m-%d-%H%M` - export DESTINATION="--destination ${DOCKER_HUB_REPO}:${DISCOURSE_VERSION}-${DATE} --destination ${DOCKER_HUB_REPO}:${DISCOURSE_VERSION} --destination ${DOCKER_HUB_REPO}:${DISCOURSE_MAJOR} --destination ${DOCKER_HUB_REPO}:${CHANNEL}" except: [] @@ -44,12 +49,8 @@ push-beta: extends: .push variables: CHANNEL: "beta" - before_script: - - export DISCOURSE_VERSION=`wget -qO- https://api.github.com/repos/discourse/discourse/tags | grep name | cut -d'"' -f4 | grep beta | head -n1` push-stable: extends: .push variables: CHANNEL: "stable" - before_script: - - export DISCOURSE_VERSION=`wget -qO- https://api.github.com/repos/discourse/discourse/tags | grep name | cut -d'"' -f4 | grep -v beta | head -n1` -- GitLab From 370cb283b01599da99aecdac212c56bb6ffa2098 Mon Sep 17 00:00:00 2001 From: unteem Date: Mon, 7 Feb 2022 12:50:25 +0100 Subject: [PATCH 10/12] fix indention & typo --- .gitlab-ci.yml | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 06c6189..48657ba 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -4,13 +4,12 @@ variables: .compute_version: &compute_version - | - if [ "$CHANNEL" == "stable" ]; then - FILTER="grep -v beta" - else - FILTER="grep beta" fi + if [ "$CHANNEL" == "stable" ]; then + FILTER="grep -v beta" + else + FILTER="grep beta" fi - export DISCOURSE_VERSION=`wget -qO- https://api.github.com/repos/discourse/discourse/tags | grep name | cut -d'"' -f4 | $FILTER | head -n1` - .test: image: name: gcr.io/kaniko-project/executor:debug @@ -18,7 +17,7 @@ variables: variables: DESTINATION: "--no-push" script: - - *compute_long_version + - *compute_version - export DISCOURSE_MAJOR=`echo $DISCOURSE_VERSION | cut -d"." -f1-3` - export DESTINATION="--destination ${DOCKER_HUB_REPO}:${DISCOURSE_VERSION}-${DATE_TAG} --destination ${DOCKER_HUB_REPO}:${DISCOURSE_VERSION} --destination ${DOCKER_HUB_REPO}:${DISCOURSE_MAJOR} --destination ${DOCKER_HUB_REPO}:beta" - /kaniko/executor --context . ${DESTINATION} --build-arg DISCOURSE_VERSION=$DISCOURSE_VERSION -- GitLab From 2fe5bc0447c1b5cc55e1e6b278ab88c4716fe442 Mon Sep 17 00:00:00 2001 From: unteem Date: Mon, 7 Feb 2022 12:57:14 +0100 Subject: [PATCH 11/12] fix ci --- .gitlab-ci.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 48657ba..66fb0b5 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -3,11 +3,7 @@ variables: DOCKER_HUB_REPO: libresh/discourse .compute_version: &compute_version - - | - if [ "$CHANNEL" == "stable" ]; then - FILTER="grep -v beta" - else - FILTER="grep beta" fi + - if [ "$CHANNEL" == "stable" ]; then export FILTER="grep -v beta"; else export FILTER="grep beta"; fi - export DISCOURSE_VERSION=`wget -qO- https://api.github.com/repos/discourse/discourse/tags | grep name | cut -d'"' -f4 | $FILTER | head -n1` .test: -- GitLab From 3fcc3ae92b13b1429c261f49a42ed114420d0390 Mon Sep 17 00:00:00 2001 From: unteem Date: Mon, 7 Feb 2022 12:58:53 +0100 Subject: [PATCH 12/12] fix ci --- .gitlab-ci.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 66fb0b5..ad0a67b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -15,7 +15,6 @@ variables: script: - *compute_version - export DISCOURSE_MAJOR=`echo $DISCOURSE_VERSION | cut -d"." -f1-3` - - export DESTINATION="--destination ${DOCKER_HUB_REPO}:${DISCOURSE_VERSION}-${DATE_TAG} --destination ${DOCKER_HUB_REPO}:${DISCOURSE_VERSION} --destination ${DOCKER_HUB_REPO}:${DISCOURSE_MAJOR} --destination ${DOCKER_HUB_REPO}:beta" - /kaniko/executor --context . ${DESTINATION} --build-arg DISCOURSE_VERSION=$DISCOURSE_VERSION except: - master @@ -34,7 +33,6 @@ test-stable: extends: .test before_script: - cp $DOCKER_SECRET_CONFIG /kaniko/.docker/config.json - - export DATE=`date +%Y-%m-%d-%H%M` - export DESTINATION="--destination ${DOCKER_HUB_REPO}:${DISCOURSE_VERSION}-${DATE} --destination ${DOCKER_HUB_REPO}:${DISCOURSE_VERSION} --destination ${DOCKER_HUB_REPO}:${DISCOURSE_MAJOR} --destination ${DOCKER_HUB_REPO}:${CHANNEL}" except: [] only: -- GitLab