Skip to content

Commit

Permalink
Add Harbor *photon Rock images
Browse files Browse the repository at this point in the history
The Harbor project has some Photon-OS based images:

* docker.io/goharbor/nginx-photon:v2.10.2
* docker.io/goharbor/registry-photon:v2.10.2
* docker.io/goharbor/trivy-adapter-photon:v2.10.2
* docker.io/goharbor/redis-photon:v2.10.2
* docker.io/goharbor/harbor-portal:v2.10.2

We're defining Rock drop-in replacements, which obviously will
not be Photon based.

Note that the reference images have an install_cert.sh script that
is a no-op on non-Photon images. We're keeping it for now, mostly
for consistency.
  • Loading branch information
petrutlucian94 committed Jul 12, 2024
1 parent 5108a1c commit 42ce17a
Show file tree
Hide file tree
Showing 6 changed files with 1,255 additions and 0 deletions.
44 changes: 44 additions & 0 deletions v2.10.2/nginx-photon/rockcraft.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: nginx
summary: Rock replacement for the Harbor Nginx image.
description: >
This rock is a drop in replacement for the
docker.io/goharbor/nginx-photon:v2.10.2 image.
# Based on the following:
# https://github.com/goharbor/harbor/tree/v2.10.2/make/photon/nginx
version: v2.10.2
license: Apache-2.0

base: [email protected]
build-base: [email protected]
platforms:
amd64:
arm64:

services:
nginx:
command: nginx -g daemon off
override: replace
startup: enabled
user: nginx
group: nginx

parts:
nginx-user:
plugin: nil
overlay-script: |
groupadd -R $CRAFT_OVERLAY -g 10000 nginx
useradd -R $CRAFT_OVERLAY -u 10000 -g 10000 \
-d /home/nginx -s /bin/bash -m nginx
nginx:
after: [nginx-user]
plugin: nil
stage-packages: [nginx]
override-build: |
mkdir -p $CRAFT_PART_INSTALL/var/log/nginx
ln -sf /dev/stdout $CRAFT_PART_INSTALL/var/log/nginx/access.log
ln -sf /dev/stderr $CRAFT_PART_INSTALL/var/log/nginx/error.log
# TODO: the upstream image defines a healthcheck, stop signal and a volume,
# should/can we do the same?
84 changes: 84 additions & 0 deletions v2.10.2/portal/rockcraft.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: portal
summary: Rock replacement for the Harbor Portal image.
description: >
This rock is a drop in replacement for the
docker.io/goharbor/harbor-portal:v2.10.2 image.
# Based on the following:
# https://github.com/goharbor/harbor/tree/v2.10.2/make/photon/portal
version: v2.10.2
license: Apache-2.0

base: [email protected]
build-base: [email protected]
platforms:
amd64:
arm64:

services:
nginx:
command: nginx -g daemon off
override: replace
startup: enabled
user: nginx
group: nginx

parts:
nginx-user:
plugin: nil
overlay-script: |
groupadd -R $CRAFT_OVERLAY -g 10000 nginx
useradd -R $CRAFT_OVERLAY -u 10000 -g 10000 \
-d /home/nginx -s /bin/bash -m nginx
nginx:
after: [nginx-user]
plugin: nil
stage-packages: [nginx]
override-build: |
chown -R 10000:10000 $CRAFT_PART_INSTALL/etc/nginx
mkdir -p $CRAFT_PART_INSTALL/var/log/nginx
ln -sf /dev/stdout $CRAFT_PART_INSTALL/var/log/nginx/access.log
ln -sf /dev/stderr $CRAFT_PART_INSTALL/var/log/nginx/error.log
# TODO: the upstream image defines a healthcheck, stop signal and a volume,
# should/can we do the same?
portal:
after: [nginx]
plugin: nil
source-type: git
source: https://github.com/goharbor/harbor
source-tag: v2.10.2
source-depth: 1
build-snaps:
- node/18/stable
override-build: |
cd $CRAFT_PART_BUILD/src/portal
cp $CRAFT_PART_SRC/api/v2.0/swagger.yaml .
export NPM_CONFIG_REGISTRY=https://registry.npmjs.org
export PATH="$PATH:$CRAFT_PART_BUILD/src/portal/node_modules/.bin"
npm install ng-swagger-gen
npm install --unsafe-perm
npm run generate-build-timestamp
node --max_old_space_size=2048 \
'node_modules/@angular/cli/bin/ng' \
build --configuration production
npm install [email protected]
node -e "const yaml = require('js-yaml'); const fs = require('fs'); const swagger = yaml.load(fs.readFileSync('swagger.yaml', 'utf8')); fs.writeFileSync('swagger.json', JSON.stringify(swagger));"
cp $CRAFT_PART_SRC/LICENSE dist/
cd app-swagger-ui
npm install --unsafe-perm
npm run build
mkdir -p $CRAFT_PART_INSTALL/usr/share/nginx/html
cp -r $CRAFT_PART_BUILD/src/portal/dist/* $CRAFT_PART_INSTALL/usr/share/nginx/html/
cp $CRAFT_PART_BUILD/src/portal/swagger.json $CRAFT_PART_INSTALL/usr/share/nginx/html/
cp -r $CRAFT_PART_BUILD/src/portal/app-swagger-ui/dist/* $CRAFT_PART_INSTALL/usr/share/nginx/html/
chown -R 10000:10000 $CRAFT_PART_INSTALL/usr/share/nginx/html
64 changes: 64 additions & 0 deletions v2.10.2/redis-photon/rockcraft.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: redis
summary: Rock replacement for the Harbor Redis image.
description: >
This rock is a drop in replacement for the
docker.io/goharbor/redis-photon:v2.10.2 image.
# Based on the following:
# https://github.com/goharbor/harbor/tree/v2.10.2/make/photon/redis
version: v2.10.2
license: Apache-2.0

base: [email protected]
build-base: [email protected]
platforms:
amd64:
arm64:

package-repositories:
- type: apt
components: [main]
suites: [jammy]
key-id: 54318FA4052D1E61A6B6F7BB5F4349D6BF53AA0C
url: https://packages.redis.io/deb
priority: always

services:
redis:
command: redis-server /etc/redis.conf
override: replace
startup: enabled
user: redis
group: redis
# working-dir: /var/lib/redis

parts:
redis-user:
plugin: nil
overlay-script: |
groupadd -R $CRAFT_OVERLAY -g 999 redis
useradd -R $CRAFT_OVERLAY -u 999 -g 999 -c "Redis Database Server" \
-d /var/lib/redis -s /sbin/nologin -m redis
image-prep:
after: [redis-user]
plugin: nil
source-type: git
source: https://github.com/goharbor/harbor
source-tag: v2.10.2
source-depth: 1
override-build: |
mkdir -p $CRAFT_PART_INSTALL/usr/bin
mkdir -p $CRAFT_PART_INSTALL/etc
cd $CRAFT_PART_SRC
cp ./make/photon/redis/docker-healthcheck $CRAFT_PART_INSTALL/usr/bin
cp ./make/photon/redis/redis.conf $CRAFT_PART_INSTALL/etc/redis.conf
chown 999:999 $CRAFT_PART_INSTALL/etc/redis.conf
chmod +x $CRAFT_PART_INSTALL/usr/bin/docker-healthcheck
redis:
after: [image-prep]
plugin: nil
stage-packages: [redis]
# TODO: the upstream image defines a healthcheck and a volume,
# should/can we do the same?
Loading

0 comments on commit 42ce17a

Please sign in to comment.