Skip to content

Commit

Permalink
Create container image for finkctl
Browse files Browse the repository at this point in the history
  • Loading branch information
fjammes committed Dec 28, 2023
1 parent 68a1d41 commit 4f9bc3d
Show file tree
Hide file tree
Showing 7 changed files with 188 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .ciux
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: v1alpha1
registry: gitlab-registry.in2p3.fr/astrolabsoftware/fink
dependencies:
- image: gitlab-registry.in2p3.fr/astrolabsoftware/fink/spark-py:k8s-3.4.1
labels:
build: "true"
27 changes: 27 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Operator Logs**
```
<Paste the logs here>
<Run `kubectl logs -l name=xrootd-operator` to get the logs>
```
104 changes: 104 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
# Qserv operator CI workflow
---
name: "CI"
on:
push:
pull_request:
branches:
- main
env:
CIUXCONFIG: /tmp/ciux.sh
CIUX_VERSION: v0.0.1-rc7
jobs:
build:
name: Build image
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/setup-go@v4
with:
go-version: '1.21.4'
- name: Install ciux
run: go install github.com/k8s-school/ciux@"${{ env.CIUX_VERSION }}"
- name: Check dependencies consistency
run: ciux ignite $PWD
- name: Declare Variables
id: vars
shell: bash
run: |
DIR="$PWD"
. ./conf.sh
echo "IMAGE=${IMAGE}" >> $GITHUB_ENV
echo "IMAGE=${IMAGE}"
- name: Build finkctl image
run: |
./build.sh
- name: Export finkctl image
run: |
docker images
echo "${{ env.IMAGE }}"
mkdir -p artifacts
docker save "${{ env.IMAGE }}" > artifacts/image.tar
echo "${{ env.IMAGE }}" > artifacts/image-tag
- uses: actions/upload-artifact@v2
with:
name: docker-artifact
path: artifacts
image-analysis:
name: Analyze image
runs-on: ubuntu-22.04
permissions:
security-events: write
needs: build
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Download image
uses: actions/download-artifact@v3
with:
name: docker-artifact
path: artifacts
- name: Load image in local registry
run: |
docker load --input artifacts/image.tar
echo "IMAGE=$(cat artifacts/artifacts/image-tag)" >> $GITHUB_ENV
- name: Scan finkctl image
uses: anchore/scan-action@v3
id: scan
with:
image: "${{ env.IMAGE }}"
fail-build: false
- name: Display SARIF report
run: |
cat ${{ steps.scan.outputs.sarif }}
- name: upload Anchore scan SARIF report
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: ${{ steps.scan.outputs.sarif }}
push:
name: Push image to registry
runs-on: ubuntu-22.04
needs: build
steps:
- name: Download image
uses: actions/download-artifact@v3
with:
name: docker-artifact
path: artifacts
- name: Load image in local registry
run: |
docker load --input artifacts/image.tar
echo "IMAGE=$(cat artifacts/image-tag)" >> $GITHUB_ENV
- name: Login to DockerHub
uses: docker/login-action@v2
with:
registry: gitlab-registry.in2p3.fr
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_TOKEN }}
- name: Push image to container registry
run: |
docker push ${{ env.IMAGE }}
12 changes: 12 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
ARG spark_py_image

# Build stage
FROM golang:1.21 AS builder
WORKDIR /app
COPY . .
RUN go build -o bin

# Final stage
FROM ${spark_py_image}
COPY --from=builder /app/bin /bin
CMD ["/bin"]
33 changes: 33 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash

# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

# Create docker image containing fink-broker for k8s

# @author Fabrice Jammes

set -euxo pipefail


DIR=$(cd "$(dirname "$0")"; pwd -P)

ciux ignite refresh "$DIR"
. $DIR/conf.sh

# Build image
docker image build --tag "$IMAGE" --build-arg spark_py_image="$ASTROLABSOFTWARE_FINK_SPARK_PY_IMAGE" "$DIR"

1 change: 0 additions & 1 deletion cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,4 @@ func Version() (version, sum string) {
sum = b.Main.Sum
}
return version, sum

}
6 changes: 6 additions & 0 deletions conf.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
. "$CIUXCONFIG"

# Container image
TAG="$FINKCTL_VERSION"
IMAGE="gitlab-registry.in2p3.fr/astrolabsoftware/fink/finkctl:$TAG"

0 comments on commit 4f9bc3d

Please sign in to comment.