Skip to content

Commit

Permalink
Add rockfile and adapt the charm for it
Browse files Browse the repository at this point in the history
  • Loading branch information
nrobinaubertin committed Aug 10, 2023
1 parent 2acfb36 commit 860f014
Show file tree
Hide file tree
Showing 12 changed files with 206 additions and 178 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/integration_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ on:

jobs:
integration-tests:
uses: canonical/operator-workflows/.github/workflows/integration_test.yaml@main
uses: canonical/operator-workflows/.github/workflows/integration_test.yaml@4e5a4c88987c9dccef264c130f47cd3764cda4d6
secrets: inherit
with:
chaos-app-label: app.kubernetes.io/name=discourse-k8s
chaos-duration: 600
chaos-enabled: false
chaos-experiments: pod-delete
chaos-status-duration: 300
extra-arguments: --localstack-address 172.17.0.1 -m "not (requires_secrets)"
extra-arguments: --localstack-address 172.17.0.1
pre-run-script: localstack-installation.sh
trivy-image-config: "trivy.yaml"
43 changes: 0 additions & 43 deletions .github/workflows/integration_test_with_secrets.yaml

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ venv
env
.pytest_cache
.mypy_cache
*.rock
2 changes: 1 addition & 1 deletion .licenserc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ header:
- 'LICENSE'
- 'trivy.yaml'
- 'zap_rules.tsv'
- 'image/patches/**'
- 'discourse_rock/patches/**'
- 'lib/**'
comment: on-failure
110 changes: 0 additions & 110 deletions discourse.Dockerfile

This file was deleted.

File renamed without changes.
File renamed without changes.
194 changes: 194 additions & 0 deletions discourse_rock/rockcraft.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
# Copyright 2023 Canonical Ltd.
# See LICENSE file for licensing details.

name: discourse
summary: Discourse rock
description: Discourse OCI image for the Discourse charm
base: ubuntu:20.04
license: Apache-2.0
version: "1.0"
platforms:
amd64:
parts:
debug-tools:
plugin: nil
stage-packages:
- git
- coreutils
- bash
- curl
- vim
install-node:
plugin: nil
source: .
build-environment:
- NODE_VERSION: "18.15.0"
- YARN_VERSION: "1.22.19"
- ARCH: "x64"
overlay-script: |
node_uri="https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-${ARCH}.tar.gz"
curl -Ls $node_uri | tar xzf - -C $CRAFT_OVERLAY/ --skip-old-files --no-same-owner --strip-components=1
install-yarn:
plugin: nil
after:
- install-node
source: .
build-environment:
- YARN_VERSION: "1.22.19"
- ARCH: "x64"
overlay-script: |
yarn_uri="https://github.com/yarnpkg/yarn/releases/download/v${YARN_VERSION}/yarn-v${YARN_VERSION}.tar.gz"
curl -Ls $yarn_uri | tar xzf - -C $CRAFT_OVERLAY/ --skip-old-files --no-same-owner --strip-components=1
install-terser:
plugin: nil
source: .
after:
- install-node
overlay-script: |
$CRAFT_OVERLAY/usr/bin/node $CRAFT_OVERLAY/usr/bin/npm --prefix $CRAFT_OVERLAY/usr/local/ i -g terser
install-runtime-packages:
plugin: nil
overlay-packages:
- brotli
- gettext-base
- gifsicle
- git
- imagemagick
- jhead
- jpegoptim
- libjpeg-turbo-progs
- libpq-dev
- libssl-dev
- libxml2-dev
- libxslt1-dev
- libz-dev
- optipng
- pngquant
- redis-tools
- ruby2.7
- ruby2.7-dev
- tzdata
- ubuntu-dev-tools
- zlib1g-dev
get-discourse:
plugin: dump
after:
- install-yarn
- install-runtime-packages
source: https://github.com/discourse/discourse.git
source-depth: 1
source-tag: v2.8.14
source-type: git
override-build: |
craftctl default
mkdir -p tmp/backups/default
mkdir -p public/backups/default
mkdir -p public/uploads/default
mkdir -p log/production.log
mkdir -p srv/discourse/app/bin
touch log/production.log
touch log/unicorn-stderr.log
yarn install --production --frozen-lockfile
organize:
"*.*": srv/discourse/app/
"*": srv/discourse/app/
".*": srv/discourse/app/
get-solved-plugin-source:
plugin: dump
source: https://github.com/discourse/discourse-solved.git
source-depth: 1
source-commit: d6c8089ca38611b09a8edb29d64f359bcef11f11
after:
- get-discourse
organize:
"*": srv/discourse/app/plugins/discourse-solved/
get-markdown-note-plugin-source:
plugin: dump
after:
- get-discourse
source: https://github.com/canonical-web-and-design/discourse-markdown-note.git
source-depth: 1
organize:
"*": srv/discourse/app/plugins/discourse-markdown-note/
get-mermaid-plugin-source:
plugin: dump
after:
- get-discourse
source: https://github.com/unfoldingWord-dev/discourse-mermaid.git
source-depth: 1
organize:
"*": srv/discourse/app/plugins/discourse-mermaid/
get-saml-plugin-source:
plugin: dump
after:
- get-discourse
source: https://github.com/discourse/discourse-saml.git
source-depth: 1
override-build: |
craftctl default
grep -e ^gem plugin.rb >> Gemfile
organize:
"*": srv/discourse/app/plugins/discourse-saml/
get-patches:
plugin: dump
source: patches
organize:
"*": srv/discourse/app/patches/
apply-patches:
plugin: nil
build-packages:
- git
after:
- get-discourse
- get-patches
override-stage: |
git -C srv/discourse/app apply patches/lp1903695.patch
git -C srv/discourse/app apply patches/anonymize_user.patch
sed -i 's/config.assets.js_compressor = :uglifier/config.assets.js_compressor = Uglifier.new(:harmony => true)/g' srv/discourse/app/config/environments/production.rb
sed -i '1s/^/require "uglifier"\n/' srv/discourse/app/config/environments/production.rb
install-gems:
plugin: nil
after:
- get-discourse
- get-saml-plugin-source
- apply-patches
build-packages:
- gettext-base
- gifsicle
- git
- imagemagick
- jhead
- jpegoptim
- libjpeg-turbo-progs
- libpq-dev
- libssl-dev
- libxml2-dev
- libxslt1-dev
- libz-dev
- optipng
- pngquant
- redis-tools
- ruby2.7
- ruby2.7-dev
- tzdata
- ubuntu-dev-tools
- zlib1g-dev
override-build: |
cd $CRAFT_STAGE/srv/discourse/app
gem install -n "bin" bundler
sed -i 's/rexml (3.2.5)/rexml (3.2.6)/' Gemfile.lock
echo "gem 'prometheus_exporter'" >> Gemfile
echo "gem 'rexml', '3.2.6'" >> Gemfile
bin/bundle install
bin/bundle install --gemfile="plugins/discourse-saml/Gemfile"
organize:
'/usr/local/bin/prometheus_exporter': usr/local/bin/
'/var/lib/gems': var/lib/gems
'srv/discourse/app/bin/*': srv/discourse/app/bin/
'srv/discourse/app/Rakefile': srv/discourse/app/
'srv/discourse/app/bundle': srv/discourse/app/
get-scripts:
plugin: dump
source: scripts
organize:
"*": srv/scripts/
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
export UNICORN_BIND_ALL=0.0.0.0
export UNICORN_SIDEKIQS=1

su -s /bin/bash -c "${CONTAINER_APP_ROOT}/app/bin/bundle exec prometheus_exporter" &
su -s /bin/bash -c "${CONTAINER_APP_ROOT}/app/bin/unicorn -c ${CONTAINER_APP_ROOT}/app/config/unicorn.conf.rb" "${CONTAINER_APP_USERNAME}" &
cd "$CONTAINER_APP_ROOT/app" || exit

bin/bundle exec prometheus_exporter &
bin/unicorn -c config/unicorn.conf.rb &

# If one of the processes exits, the other one will be killed so that the pod will be restarted by the failing probes
wait -n
Expand Down
Loading

0 comments on commit 860f014

Please sign in to comment.