Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Harbor *photon Rock images #4

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions v2.10.2/nginx-photon/rockcraft.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
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: |
chown -R 10000:10000 $CRAFT_PART_INSTALL/etc/nginx

mkdir -p $CRAFT_PART_INSTALL/var/log/nginx
chown -R 10000:10000 $CRAFT_PART_INSTALL/var/log/nginx

# The reference image creates these symlinks, however a volume is expected
# to be mounted at the given location.
#
# Also, the github image builder job fails when having these links:
# https://paste.ubuntu.com/p/zsDHyR2NY4/plain/
#
# 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?
95 changes: 95 additions & 0 deletions v2.10.2/portal/rockcraft.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
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
chown -R 10000:10000 $CRAFT_PART_INSTALL/var/log/nginx

# The reference image creates these symlinks, however a volume is expected
# to be mounted at the given location.
#
# Also, the github image builder job fails when having these links:
# https://paste.ubuntu.com/p/zsDHyR2NY4/plain/
#
# ln -sf /dev/stdout $CRAFT_PART_INSTALL/var/log/nginx/access.log
# ln -sf /dev/stderr $CRAFT_PART_INSTALL/var/log/nginx/error.log

# Drop the sample html dir, we'll add the portal files instead and we
# have to avoid staging the same files with different content.
rm -rf $CRAFT_PART_INSTALL/usr/share/nginx/html/

# 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

# https://github.com/cypress-io/cypress-documentation/issues/5868
npm install cypress --save-dev --foreground-scripts

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
Loading