diff --git a/.github/workflows/dind.yml b/.github/workflows/dind.yml deleted file mode 100644 index 64b19eb4914dafc7473db69ffcf71d9e1c7fbf2b..0000000000000000000000000000000000000000 --- a/.github/workflows/dind.yml +++ /dev/null @@ -1,38 +0,0 @@ -name: Docker-in-Docker -on: - workflow_dispatch: - inputs: - version: - description: 'The version to tag the DIND image with e.g. v1.0.0' - required: true - type: string - -permissions: - packages: write - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - - name: Login to GitHub Container Registry - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - - name: Build and push Docker image - uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc - with: - context: dind - platforms: linux/amd64,linux/arm64 - push: true - tags: ghcr.io/jumppad-labs/dind:${{inputs.version}} diff --git a/.github/workflows/kubernetes.yml b/.github/workflows/kubernetes.yml deleted file mode 100644 index a0cbcf95965e9ad01cf656038bf97a12242bdf02..0000000000000000000000000000000000000000 --- a/.github/workflows/kubernetes.yml +++ /dev/null @@ -1,81 +0,0 @@ -name: Kubernetes -on: - push: - schedule: - - cron: '0 0 * * *' - workflow_dispatch: - inputs: - version: - description: 'The version of Kubernetes to build an image for e.g. v1.28.3' - required: true - type: string - -permissions: - packages: write - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Get Kubernetes version - id: collect - run: |- - # Get latest Kubernetes version - KUBERNETES_VERSION=${{inputs.version}} - if [ -z "$KUBERNETES_VERSION" ]; then - KUBERNETES_VERSION=$(curl -s https://registry.hub.docker.com/v2/repositories/rancher/k3s/tags\?name\=k3s1\&page_size\=50 | \ - jq -r '.results[].name | select(contains("-rc") | not) | select(endswith("k3s1")) | sub("(?<version>[0-9]+\\.[0-9]+\\.[0-9]+).*";.version)' | \ - sort -r | \ - head -n 1) - CURRENT_VERSION=$(curl --silent --fail -L \ - -H "Accept: application/vnd.github+json" \ - -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ - -H "X-GitHub-Api-Version: 2022-11-28" \ - "https://api.github.com/orgs/jumppad-labs/packages/container/kubernetes/versions" | \ - jq -r '.[].metadata.container.tags[] | select( . != null )' | \ - sort -r | \ - head -n 1) - fi - - echo "version=$KUBERNETES_VERSION" >> "$GITHUB_OUTPUT" - echo "current=$CURRENT_VERSION" >> "$GITHUB_OUTPUT" - - echo $KUBERNETES_VERSION - echo $CURRENT_VERSION - - - name: Login to GitHub Container Registry - if: steps.collect.outputs.version != steps.collect.outputs.current - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Set up QEMU - if: steps.collect.outputs.version != steps.collect.outputs.current - uses: docker/setup-qemu-action@v2 - - - name: Set up Docker Buildx - if: steps.collect.outputs.version != steps.collect.outputs.current - uses: docker/setup-buildx-action@v2 - - - name: Build and push Docker image - if: steps.collect.outputs.version != steps.collect.outputs.current - uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc - with: - context: kubernetes - platforms: linux/amd64,linux/arm64 - build-args: | - KUBERNETES_VERSION=${{steps.collect.outputs.version}} - push: true - tags: ghcr.io/jumppad-labs/kubernetes:${{steps.collect.outputs.version}} - - - name: Test built image - if: steps.collect.outputs.version != steps.collect.outputs.current - run: |- - # Install Jumppad - curl https://jumppad.dev/install | bash - - # Test the image - jumppad test --tags @Single --var version=${{steps.collect.outputs.version}} ./kubernetes/tests \ No newline at end of file diff --git a/.github/workflows/nomad.yml b/.github/workflows/nomad.yml deleted file mode 100644 index 7b58ece57c61fbb630c5820e79a8afa95c59a3f1..0000000000000000000000000000000000000000 --- a/.github/workflows/nomad.yml +++ /dev/null @@ -1,86 +0,0 @@ -name: Nomad -on: - push: - schedule: - - cron: '0 0 * * *' - workflow_dispatch: - inputs: - version: - description: 'The version of Nomad to build an image for e.g. v1.6.3' - required: true - type: string - -permissions: - packages: write - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Get Nomad version - id: collect - run: |- - # Get latest Nomad version - NOMAD_VERSION=${{inputs.version}} - if [ -z "$NOMAD_VERSION" ]; then - NOMAD_VERSION=$(curl --silent "https://api.github.com/repos/hashicorp/nomad/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/') - CURRENT_VERSION=$(curl --silent --fail -L \ - -H "Accept: application/vnd.github+json" \ - -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ - -H "X-GitHub-Api-Version: 2022-11-28" \ - "https://api.github.com/orgs/jumppad-labs/packages/container/nomad/versions" | \ - jq -r '.[].metadata.container.tags[] | select( . != null )' | \ - sort -V -r | \ - head -n 1) - fi - - echo "version=$NOMAD_VERSION" >> "$GITHUB_OUTPUT" - echo "current=$CURRENT_VERSION" >> "$GITHUB_OUTPUT" - - echo $NOMAD_VERSION - echo $CURRENT_VERSION - - - name: Remove v in Tag - id: version - uses: ashley-taylor/regex-property-action@v1.0 - with: - value: ${{steps.collect.outputs.version}} - regex: "v" - replacement: "" - - - name: Login to GitHub Container Registry - if: steps.collect.outputs.version != steps.collect.outputs.current - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Set up QEMU - if: steps.collect.outputs.version != steps.collect.outputs.current - uses: docker/setup-qemu-action@v2 - - - name: Set up Docker Buildx - if: steps.collect.outputs.version != steps.collect.outputs.current - uses: docker/setup-buildx-action@v2 - - - name: Build and push Docker image - if: steps.collect.outputs.version != steps.collect.outputs.current - uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc - with: - context: nomad - platforms: linux/amd64,linux/arm64 - build-args: | - NOMAD_VERSION=${{steps.version.outputs.value}} - push: true - tags: ghcr.io/jumppad-labs/nomad:${{steps.collect.outputs.version}} - - - name: Test built image - if: steps.collect.outputs.version != steps.collect.outputs.current - run: |- - # Install Jumppad - curl https://jumppad.dev/install | bash - - # Test the image - jumppad test --tags @Single --var version=${{steps.collect.outputs.version}} ./nomad/tests \ No newline at end of file diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000000000000000000000000000000000000..b684fb4bc7b82576ecb5032308faf211fb49c8e6 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,58 @@ +stages: + - build + - tag-latest + - trigger + +variables: + IMAGE_TAG: $CI_COMMIT_REF_SLUG-$CI_PIPELINE_ID + NOMAD_VERSION: 1.9.1 + CONSUL_VERSION: 1.20.1 + TARGETARCH: amd64 + +before_script: + - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY + +.default_rules: + rules: + - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH + +build: + stage: build + tags: + - dind + parallel: + matrix: + - IMAGE_TYPE: + - dind + - kubernetes + - nomad + - pind + script: + - cd ${IMAGE_TYPE} + - docker pull {$CI_REGISTRY_IMAGE}/${IMAGE_TYPE}:latest || true + - docker build --build-arg NOMAD_VERSION=${NOMAD_VERSION} --build-arg CONSUL_VERSION=${CONSUL_VERSION} --build-arg TARGETARCH=${TARGETARCH} --cache-from ${CI_REGISTRY_IMAGE}/${IMAGE_TYPE}:latest --tag ${CI_REGISTRY_IMAGE}/${IMAGE_TYPE}:${IMAGE_TAG} . + - docker push ${CI_REGISTRY_IMAGE}/${IMAGE_TYPE}:${IMAGE_TAG} + +tag-latest: + stage: tag-latest + tags: + - dind + parallel: + matrix: + - IMAGE_TYPE: + - dind + - kubernetes + - nomad + - pind + script: + - docker pull ${CI_REGISTRY_IMAGE}/${IMAGE_TYPE}:${IMAGE_TAG} + - docker tag ${CI_REGISTRY_IMAGE}/${IMAGE_TYPE}:${IMAGE_TAG} ${CI_REGISTRY_IMAGE}/${IMAGE_TYPE}:latest + - docker push ${CI_REGISTRY_IMAGE}/${IMAGE_TYPE}:latest + rules: + - !reference [.default_rules, rules] + +trigger-tango: + stage: trigger + trigger: lofar2.0/tango + rules: + - !reference [.default_rules, rules] diff --git a/nomad/Dockerfile b/nomad/Dockerfile index bce2c404692513a4badc799fe0fa1e616a5a836b..bb65b144b2c591cfce655173da5b60bf75cf878e 100644 --- a/nomad/Dockerfile +++ b/nomad/Dockerfile @@ -1,6 +1,7 @@ -FROM ghcr.io/jumppad-labs/dind:v1.1.2 +FROM git.astron.nl:5000/lofar2.0/jumppad-docker-files/dind:latest ARG NOMAD_VERSION +ARG CONSUL_VERSION ARG TARGETARCH ENV CNI_PLUGINS=1.5.1 @@ -16,6 +17,12 @@ RUN curl -L https://releases.hashicorp.com/nomad/${NOMAD_VERSION}/nomad_${NOMAD_ chmod +x /usr/bin/nomad && \ rm /tmp/nomad.zip +RUN curl -L https://releases.hashicorp.com/consul/${CONSUL_VERSION}/consul_${CONSUL_VERSION}_linux_${TARGETARCH}.zip -o /tmp/consul.zip && \ + cd /tmp && \ + unzip consul.zip consul -d /usr/bin && \ + chmod +x /usr/bin/consul && \ + rm /tmp/consul.zip + # Install the CNI Plugins RUN curl -L https://github.com/containernetworking/plugins/releases/download/v${CNI_PLUGINS}/cni-plugins-linux-${TARGETARCH}-v${CNI_PLUGINS}.tgz -o /tmp/cni.tgz && \ mkdir -p /opt/cni/bin && \ @@ -83,4 +90,4 @@ RUN mkdir -p /var/lib/nomad COPY files/config.hcl /etc/nomad.d/config.hcl COPY --chmod=0755 files/nomad.sh /usr/local/bin/nomad.sh -ENTRYPOINT ["/usr/local/bin/nomad.sh"] \ No newline at end of file +ENTRYPOINT ["/usr/local/bin/nomad.sh"] diff --git a/nomad/files/nomad.sh b/nomad/files/nomad.sh index 2a6c8ff2c118a0064acd5e38478e2efa945fb0d2..2d53427753f0fb853851229a5f1a1ed485daffff 100644 --- a/nomad/files/nomad.sh +++ b/nomad/files/nomad.sh @@ -13,6 +13,9 @@ fi # Start the docker daemon /usr/local/bin/dockerd.sh & +# Start the consul agent +/usr/bin/consul agent -config-file /etc/consul.d/config/user_config.hcl -log-level=DEBUG & + # Start the nomad agent /usr/bin/nomad agent -config /etc/nomad.d -log-level=DEBUG &