mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-04-09 12:21:17 +00:00
Move to balena-ci action for deployments
Change-type: patch Signed-off-by: Miguel Casqueira <miguel@balena.io>
This commit is contained in:
parent
f073652603
commit
959d425a5c
@ -1,4 +1,4 @@
|
||||
name: balenaCloud staging
|
||||
name: balenaCloud
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
@ -13,12 +13,13 @@ jobs:
|
||||
fail-fast: true
|
||||
matrix:
|
||||
arch: [aarch64, amd64, armv7hf, i386, rpi]
|
||||
environment: [ { tld: balena-cloud.com, token_prop_name: BALENA_TOKEN }, { tld: balena-staging.com, token_prop_name: BALENA_STAGING_TOKEN } ]
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: balena-io/balena-ci@master
|
||||
name: 'Deploy to ${{ matrix.environment.tld }}'
|
||||
with:
|
||||
balena_token: ${{ secrets.BALENA_STAGING_TOKEN }}
|
||||
balena_token: ${{ secrets[matrix.environment.token_prop_name] }}
|
||||
fleet: 'balena_os/${{ matrix.arch }}-supervisor'
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
versionbot: true
|
||||
environment: balena-staging.com
|
||||
environment: ${{ matrix.environment.tld }}
|
132
Dockerfile
132
Dockerfile
@ -1,132 +0,0 @@
|
||||
ARG ARCH=amd64
|
||||
ARG NODE_VERSION=12.16.2
|
||||
|
||||
FROM balenalib/$ARCH-alpine-supervisor-base:3.11 as BUILD
|
||||
|
||||
ARG ARCH
|
||||
ARG NODE_VERSION
|
||||
ARG NODE_ARCHIVE="node-no-intl-v${NODE_VERSION}-linux-alpine-${ARCH}.tar.gz"
|
||||
ARG S3_BASE="https://resin-packages.s3.amazonaws.com"
|
||||
ARG NODE_LOCATION="${S3_BASE}/node/v${NODE_VERSION}/${NODE_ARCHIVE}"
|
||||
|
||||
# DO NOT REMOVE THE cross-build-* COMMANDS
|
||||
# The following commands are absolutely needed. When we
|
||||
# build for ARM architectures, we run this Dockerfile
|
||||
# through sed, which uncomments these lines. There were
|
||||
# other options for achieving the same setup, but this seems
|
||||
# to be the least intrusive. The commands start commented
|
||||
# out because the default build for balenaCI is amd64 (and
|
||||
# we can't run any sed preprocessing on it there)
|
||||
# RUN ["cross-build-start"]
|
||||
|
||||
WORKDIR /usr/src/app
|
||||
|
||||
RUN apk add --no-cache \
|
||||
g++ \
|
||||
git \
|
||||
make \
|
||||
python \
|
||||
curl \
|
||||
binutils \
|
||||
libgcc \
|
||||
libstdc++ \
|
||||
libuv \
|
||||
sqlite-libs \
|
||||
sqlite-dev \
|
||||
dbus-dev
|
||||
|
||||
COPY build-utils/node-sums.txt .
|
||||
|
||||
# Install node from balena's prebuilt cache
|
||||
RUN curl -SLO "${NODE_LOCATION}" \
|
||||
&& grep "${NODE_ARCHIVE}" node-sums.txt | sha256sum -c - \
|
||||
&& tar -xzf "${NODE_ARCHIVE}" -C /usr/local --strip-components=1 \
|
||||
&& rm -f "${NODE_ARCHIVE}" \
|
||||
&& strip /usr/local/bin/node
|
||||
|
||||
COPY package*.json ./
|
||||
|
||||
RUN npm ci --build-from-source --sqlite=/usr/lib
|
||||
|
||||
# We only run these commands when executing through
|
||||
# livepush, so they are presented as livepush directives
|
||||
#dev-run=apk add --no-cache ip6tables iptables
|
||||
#dev-copy=entry.sh .
|
||||
#dev-cmd-live=LIVEPUSH=1 ./entry.sh
|
||||
|
||||
COPY build-utils ./build-utils
|
||||
COPY webpack.config.js tsconfig.json tsconfig.release.json ./
|
||||
COPY src ./src
|
||||
COPY test ./test
|
||||
COPY typings ./typings
|
||||
|
||||
RUN npm run test-nolint \
|
||||
&& npm run build
|
||||
|
||||
# Run the production install here, to avoid the npm dependency on
|
||||
# the later stage
|
||||
RUN npm ci --production --no-optional --unsafe-perm --build-from-source --sqlite=/usr/lib \
|
||||
&& npm cache clean --force \
|
||||
# For some reason this doesn't get cleared with the other
|
||||
# cache
|
||||
&& rm -rf node_modules/.cache \
|
||||
# Remove various uneeded filetypes in order to reduce space
|
||||
# We also remove the spurious node.dtps, see https://github.com/mapbox/node-sqlite3/issues/861
|
||||
&& find . -path '*/coverage/*' -o -path '*/test/*' -o -path '*/.nyc_output/*' \
|
||||
-o -name '*.tar.*' -o -name '*.in' -o -name '*.cc' \
|
||||
-o -name '*.c' -o -name "*.ts" -o -name '*.eslintrc' \
|
||||
-o -name '*.h' -o -name '*.html' -o -name '*.markdown' \
|
||||
-o -name '*.md' -o -name '*.patch' -o -name '*.png' \
|
||||
-o -name '*.yml' \
|
||||
-delete \
|
||||
&& find . -type f -path '*/node_modules/sqlite3/deps*' -delete \
|
||||
&& find . -type f -path '*/node_modules/knex/build*' -delete \
|
||||
&& rm -rf node_modules/sqlite3/node.dtps
|
||||
|
||||
|
||||
# RUN ["cross-build-end"]
|
||||
|
||||
FROM balenalib/$ARCH-alpine-supervisor-base:3.11
|
||||
|
||||
# RUN ["cross-build-start"]
|
||||
|
||||
RUN apk add --no-cache \
|
||||
ca-certificates \
|
||||
kmod \
|
||||
iptables \
|
||||
ip6tables \
|
||||
rsync \
|
||||
avahi \
|
||||
dbus \
|
||||
libstdc++ \
|
||||
sqlite-libs
|
||||
|
||||
WORKDIR /usr/src/app
|
||||
|
||||
COPY --from=BUILD /usr/local/bin/node /usr/local/bin/node
|
||||
COPY --from=BUILD /usr/src/app/dist ./dist
|
||||
COPY --from=BUILD /usr/src/app/package.json ./
|
||||
COPY --from=BUILD /usr/src/app/node_modules ./node_modules
|
||||
|
||||
COPY entry.sh .
|
||||
|
||||
RUN mkdir -p rootfs-overlay && \
|
||||
(([ ! -d rootfs-overlay/lib64 ] && ln -s /lib rootfs-overlay/lib64) || true)
|
||||
|
||||
ARG ARCH
|
||||
ARG VERSION=master
|
||||
ARG DEFAULT_MIXPANEL_TOKEN=bananasbananas
|
||||
ENV CONFIG_MOUNT_POINT=/boot/config.json \
|
||||
LED_FILE=/dev/null \
|
||||
SUPERVISOR_IMAGE=balena/$ARCH-supervisor \
|
||||
VERSION=$VERSION \
|
||||
DEFAULT_MIXPANEL_TOKEN=$DEFAULT_MIXPANEL_TOKEN
|
||||
COPY avahi-daemon.conf /etc/avahi/avahi-daemon.conf
|
||||
|
||||
VOLUME /data
|
||||
HEALTHCHECK --interval=5m --start-period=1m --timeout=30s --retries=3 \
|
||||
CMD wget http://127.0.0.1:${LISTEN_PORT:-48484}/v1/healthy -O - -q
|
||||
|
||||
# RUN ["cross-build-end"]
|
||||
|
||||
CMD ["/usr/src/app/entry.sh"]
|
208
circle.yml
208
circle.yml
@ -1,208 +0,0 @@
|
||||
---
|
||||
defaults: &defaults
|
||||
docker:
|
||||
- image: library/docker:18-git
|
||||
working_directory: /tmp/build
|
||||
steps:
|
||||
- setup_remote_docker:
|
||||
version: 18.09.3
|
||||
docker_layer_caching: true
|
||||
- run:
|
||||
name: Check docker is running and install dependencies
|
||||
command: |
|
||||
docker info
|
||||
apk update && apk upgrade && apk add --no-cache \
|
||||
make \
|
||||
jq \
|
||||
bash \
|
||||
grep \
|
||||
nodejs \
|
||||
nodejs-npm \
|
||||
openssh-client
|
||||
- run:
|
||||
name: Install balena CLI and test it
|
||||
command: |
|
||||
apk add --no-cache curl python3 g++ linux-headers && \
|
||||
npm install balena-cli -g --production --unsafe-perm && \
|
||||
balena version -v
|
||||
- checkout
|
||||
- run:
|
||||
name: Initialize the submodules
|
||||
command: |
|
||||
git submodule update --init --recursive
|
||||
git clean -fxd base-image
|
||||
git submodule foreach --recursive git clean -fxd
|
||||
- run:
|
||||
name: Build $ARCH-supervisor
|
||||
no_output_timeout: 10800
|
||||
command: |
|
||||
VERSION_TAG_NO_DEBUG=v$(jq --raw-output .version package.json)
|
||||
GIT_TAG=$(git describe --tags | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' || echo "")
|
||||
VERSION_TAG="${VERSION_TAG_NO_DEBUG}${DEBUG}"
|
||||
AUTHOR=$(curl -s -H "Accept: application/vnd.github.v3+json" \
|
||||
"https://api.github.com/repos/${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}/commits/${CIRCLE_SHA1}" \
|
||||
| jq -r '.author.login')
|
||||
COMMITTER=$(curl -s -H "Accept: application/vnd.github.v3+json" \
|
||||
"https://api.github.com/repos/${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}/commits/${CIRCLE_SHA1}" \
|
||||
| jq -r '.commit.committer.email')
|
||||
|
||||
if [ "${VERSION_TAG_NO_DEBUG}" = "${GIT_TAG}" ]; then
|
||||
export EXTRA_TAG="${VERSION_TAG}"
|
||||
fi
|
||||
echo "Starting build.sh"
|
||||
if [ "$DOCKER_PASSWORD" != "" ]; then
|
||||
docker login --username $DOCKER_USERNAME --password $DOCKER_PASSWORD
|
||||
export PUSH_IMAGES=${PUSH_IMAGES}
|
||||
else
|
||||
export PUSH_IMAGES=false
|
||||
fi
|
||||
if [ "$PRODUCTION_API_TOKEN" != "" ]; then
|
||||
balena login --token $PRODUCTION_API_TOKEN
|
||||
export DEPLOY_TO_PRODUCTION=${DEPLOY_TO_PRODUCTION}
|
||||
else
|
||||
export DEPLOY_TO_PRODUCTION=false
|
||||
fi
|
||||
export DEPLOY_TO_STAGING=false
|
||||
# Create required env vars
|
||||
export TAG=$(echo ${CIRCLE_BRANCH} | sed 's/[^a-z0-9A-Z_.-]/-/g')
|
||||
export ARCH=${ARCH}
|
||||
export PROJECT_NAME=${ARCH}-supervisor
|
||||
export SERVICE_NAME=balena-supervisor
|
||||
# start the build for this architecture
|
||||
bash automation/build.sh
|
||||
if [ "${CIRCLE_BRANCH}" = "master" ] && [ "${AUTHOR}" = "balena-ci" ] && [ "${COMMITTER}" = "versionbot@balena.io" ] && [ "${DEPLOY_TO_STAGING}" = "true" ]; then
|
||||
echo "Deploying to balena API (staging)"
|
||||
BALENARC_BALENA_URL=$STAGING_API_ENDPOINT balena login --token $STAGING_API_TOKEN
|
||||
# Create a draft release first in case the second step fails
|
||||
releaseId=$(BALENARC_BALENA_URL=$STAGING_API_ENDPOINT balena deploy ${BALENA_OS_ORG}/${PROJECT_NAME} \
|
||||
--draft \
|
||||
--projectName ${PROJECT_NAME} --tag ${TAG} \
|
||||
--release-tag version ${VERSION_TAG} | sed -n 's/.*Release: //p')
|
||||
echo "Successfully deployed release ${releaseId}"
|
||||
# Set release_version as is still needed some places
|
||||
curl -X PATCH -H "Content-type: application/json" -H "Authorization: Bearer ${STAGING_API_TOKEN}" \
|
||||
"https://api.${STAGING_API_ENDPOINT}/v6/release?\$filter=commit%20eq%20'${releaseId}'%20and%20belongs_to__application/any(bta:bta/slug%20eq%20'${BALENA_OS_ORG}%2F${PROJECT_NAME}')" \
|
||||
-d "{\"release_version\": \"${VERSION_TAG}\", \"is_final\": true}"
|
||||
# Cleanup credentials just in case
|
||||
rm ~/.balena/token
|
||||
fi
|
||||
if [ "${CIRCLE_BRANCH}" = "master" ] && [ "${AUTHOR}" = "balena-ci" ] && [ "${COMMITTER}" = "versionbot@balena.io" ] && [ "${DEPLOY_TO_PRODUCTION}" = "true" ]; then
|
||||
echo "Deploying to balena API (production)"
|
||||
BALENARC_BALENA_URL=$PRODUCTION_API_ENDPOINT balena login --token $PRODUCTION_API_TOKEN
|
||||
# Create a draft release first in case the second step fails
|
||||
releaseId=$(BALENARC_BALENA_URL=$PRODUCTION_API_ENDPOINT balena deploy ${BALENA_OS_ORG}/${PROJECT_NAME} \
|
||||
--draft \
|
||||
--projectName ${PROJECT_NAME} --tag ${TAG} \
|
||||
--release-tag version ${VERSION_TAG} | sed -n 's/.*Release: //p')
|
||||
# Set release_version as is still needed some places
|
||||
curl -X PATCH -H "Content-type: application/json" -H "Authorization: Bearer ${PRODUCTION_API_TOKEN}" \
|
||||
"https://api.${PRODUCTION_API_ENDPOINT}/v6/release?\$filter=commit%20eq%20'${releaseId}'%20and%20belongs_to__application/any(bta:bta/slug%20eq%20'${BALENA_OS_ORG}%2F${PROJECT_NAME}')" \
|
||||
-d "{\"release_version\": \"${VERSION_TAG}\", \"is_final\": true}"
|
||||
# Cleanup credentials just in case
|
||||
rm ~/.balena/token
|
||||
fi
|
||||
|
||||
version: 2
|
||||
jobs:
|
||||
generic:
|
||||
docker:
|
||||
- image: balenalib/amd64-alpine-node:12
|
||||
steps:
|
||||
- checkout
|
||||
- run:
|
||||
name: Install dependencies
|
||||
command: |
|
||||
apk add dbus-dev python3 make \
|
||||
gcc libgcc libc-dev g++
|
||||
- run:
|
||||
name: Run tests
|
||||
command: |
|
||||
JOBS=max npm ci && npm test
|
||||
environment:
|
||||
DOCKER_USERNAME: travisciresin
|
||||
ARCH: amd64
|
||||
PUSH_IMAGES: 'true'
|
||||
STAGING_API_ENDPOINT: balena-staging.com
|
||||
PRODUCTION_API_ENDPOINT: balena-cloud.com
|
||||
DEBUG: ''
|
||||
amd64:
|
||||
<<: *defaults
|
||||
environment:
|
||||
DOCKER_USERNAME: travisciresin
|
||||
ARCH: amd64
|
||||
PUSH_IMAGES: 'true'
|
||||
STAGING_API_ENDPOINT: balena-staging.com
|
||||
PRODUCTION_API_ENDPOINT: balena-cloud.com
|
||||
DEPLOY_TO_PRODUCTION: 'true'
|
||||
DEPLOY_TO_STAGING: 'true'
|
||||
BALENA_OS_ORG: 'balena_os'
|
||||
DEBUG: ''
|
||||
i386:
|
||||
<<: *defaults
|
||||
environment:
|
||||
DOCKER_USERNAME: travisciresin
|
||||
ARCH: i386
|
||||
PUSH_IMAGES: 'true'
|
||||
STAGING_API_ENDPOINT: balena-staging.com
|
||||
PRODUCTION_API_ENDPOINT: balena-cloud.com
|
||||
DEPLOY_TO_PRODUCTION: 'true'
|
||||
DEPLOY_TO_STAGING: 'true'
|
||||
BALENA_OS_ORG: 'balena_os'
|
||||
DEBUG: ''
|
||||
armv7hf:
|
||||
<<: *defaults
|
||||
environment:
|
||||
DOCKER_USERNAME: travisciresin
|
||||
ARCH: armv7hf
|
||||
PUSH_IMAGES: 'true'
|
||||
STAGING_API_ENDPOINT: balena-staging.com
|
||||
PRODUCTION_API_ENDPOINT: balena-cloud.com
|
||||
DEPLOY_TO_PRODUCTION: 'true'
|
||||
DEPLOY_TO_STAGING: 'true'
|
||||
BALENA_OS_ORG: 'balena_os'
|
||||
DEBUG: ''
|
||||
aarch64:
|
||||
<<: *defaults
|
||||
environment:
|
||||
DOCKER_USERNAME: travisciresin
|
||||
ARCH: aarch64
|
||||
PUSH_IMAGES: 'true'
|
||||
STAGING_API_ENDPOINT: balena-staging.com
|
||||
PRODUCTION_API_ENDPOINT: balena-cloud.com
|
||||
DEPLOY_TO_PRODUCTION: 'true'
|
||||
DEPLOY_TO_STAGING: 'true'
|
||||
BALENA_OS_ORG: 'balena_os'
|
||||
DEBUG: ''
|
||||
rpi:
|
||||
<<: *defaults
|
||||
environment:
|
||||
DOCKER_USERNAME: travisciresin
|
||||
ARCH: rpi
|
||||
PUSH_IMAGES: 'true'
|
||||
STAGING_API_ENDPOINT: balena-staging.com
|
||||
PRODUCTION_API_ENDPOINT: balena-cloud.com
|
||||
DEPLOY_TO_PRODUCTION: 'true'
|
||||
DEPLOY_TO_STAGING: 'true'
|
||||
BALENA_OS_ORG: 'balena_os'
|
||||
DEBUG: ''
|
||||
|
||||
workflows:
|
||||
version: 2
|
||||
build_and_maybe_deploy:
|
||||
jobs:
|
||||
- generic
|
||||
- amd64:
|
||||
requires:
|
||||
- generic
|
||||
- i386:
|
||||
requires:
|
||||
- generic
|
||||
- rpi:
|
||||
requires:
|
||||
- generic
|
||||
- armv7hf:
|
||||
requires:
|
||||
- generic
|
||||
- aarch64:
|
||||
requires:
|
||||
- generic
|
Loading…
x
Reference in New Issue
Block a user