Browse Source

Import OSCW runner

master
Rafal Kupiec 4 months ago
commit
b9cfdb1fd5
Signed by: belliash
GPG Key ID: 4E829243E0CFE6B4
  1. 11
      .build.yml
  2. 41
      Dockerfile
  3. 3
      README.md
  4. 21
      files/entrypoint.sh
  5. 22
      files/github_publish

11
.build.yml

@ -0,0 +1,11 @@
pipeline:
build:
image: codingworkshop/oscw-runner:latest
secrets:
- OSCW_DOCKERHUB_USERNAME
- OSCW_DOCKERHUB_PASSWORD
commands:
- echo $OSCW_DOCKERHUB_PASSWORD | docker login -u $OSCW_DOCKERHUB_USERNAME --password-stdin
- docker build -t codingworkshop/oscw-runner:latest .
- docker push codingworkshop/oscw-runner:latest
- docker image prune -af

41
Dockerfile

@ -0,0 +1,41 @@
FROM archlinux:latest
MAINTAINER CodingWorkshop <constitutive@codingworkshop.eu.org>
# Update system base
RUN pacman -Syu --noconfirm --noprogressbar --quiet
# Install additional packages
RUN pacman -Syu --noconfirm --noprogressbar --quiet autoconf automake binutils bison cppcheck docker flex gcc git libedit libmd linux-headers patch pkgconfig texinfo wget
# Set locale
RUN echo 'en_US.UTF-8 UTF-8' > /etc/locale.gen && \
echo 'LANG=en_US.UTF-8' > /etc/locale.conf && \
locale-gen
# Install Docker-in-Docker
ENV DIND_COMMIT 3b5fac462d21ca164b3778647420016315289034
RUN wget "https://raw.githubusercontent.com/docker/docker/${DIND_COMMIT}/hack/dind" -O /usr/local/bin/dind && \
chmod a+x /usr/local/bin/dind
# Configure Docker-in-Docker
COPY files/entrypoint.sh /usr/local/bin/
RUN chmod a+x /usr/local/bin/entrypoint.sh
VOLUME /var/lib/docker
EXPOSE 2375
# Install XT toolchain
RUN wget https://github.com/xt-sys/xtchain/releases/download/2.2/xtchain-2.2-linux.tar.zst -O xtchain.tar.zst && \
mkdir -p /opt/xtchain && \
tar xapf xtchain.tar.zst -C /opt/xtchain && \
rm xtchain.tar.zst
# Install GitHub publishing script
COPY files/github_publish /usr/local/bin/
RUN chmod a+x /usr/local/bin/github_publish
# Set system path
ENV PATH="/opt/xtchain:/opt/xtchain/bin:${PATH}"
# Set default entrypoint
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
CMD []

3
README.md

@ -0,0 +1,3 @@
# OSCW Runner
OSCW runner is an official build container for CodingWorkshop projects that include classic GNU toolchain and XTChain.
It is based on the latest version of the Arch Linux base container. It is designed for use on the OSCW CI/CD platform.

21
files/entrypoint.sh

@ -0,0 +1,21 @@
#!/bin/bash
set -e
# no arguments passed
# or first arg is `-f` or `--some-option`
if [ "$#" -eq 0 -o "${1#-}" != "$1" ]; then
# add our default arguments
set -- dockerd \
--host=unix:///var/run/docker.sock \
--host=tcp://0.0.0.0:2375 \
--storage-driver=vfs \
"$@"
fi
if [ "$1" = 'dockerd' ]; then
# if we're running Docker, let's pipe through dind
# (and we'll run dind explicitly with "sh" since its shebang is /bin/bash)
set -- sh "$(which dind)" "$@"
fi
exec "$@"

22
files/github_publish

@ -0,0 +1,22 @@
#!/bin/bash
GITHUB_USERNAME="${1}"
GITHUB_TOKEN="${2}"
ASSET_NAME="${3}"
echo "Creating new GitHub release '${CI_COMMIT_TAG}'"
RESULT=$(curl --user "${GITHUB_USERNAME}:${GITHUB_TOKEN}" -X POST https://api.github.com/repos/${CI_REPO}/releases -d \
"{
\"tag_name\": \"${CI_COMMIT_TAG}\",
\"target_commitish\": \"${CI_COMMIT_SHA}\",
\"name\": \"${CI_COMMIT_TAG}\",
\"draft\": false,
\"prerelease\": false
}")
echo "Create release result: ${RESULT}"
RELEASE_ID=$(echo "${RESULT}" | python -c 'import json,sys;print(json.load(sys.stdin)["id"])')
echo "Publishing artifact: ${ASSET_NAME}"
curl --user "${GITHUB_USERNAME}:${GITHUB_TOKEN}" -X POST https://uploads.github.com/repos/${CI_REPO}/releases/${RELEASE_ID}/assets?name=${ASSET_NAME} \
--header 'Content-Type: text/javascript ' --upload-file ${ASSET_NAME}
Loading…
Cancel
Save