fix node-sqlite3 dependency in ARM builds (#131)
This commit is contained in:
parent
8f98fffb85
commit
4d09668870
49
.github/workflows/docker-image-push.yml
vendored
49
.github/workflows/docker-image-push.yml
vendored
|
@ -1,6 +1,8 @@
|
|||
name: Build (and push) multi-arch Docker image
|
||||
name: Build and push multi-arch Docker image
|
||||
|
||||
on: [push, pull_request]
|
||||
on:
|
||||
release:
|
||||
types: [published]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
@ -16,46 +18,23 @@ jobs:
|
|||
uses: actions/checkout@v1
|
||||
|
||||
- name: Docker login
|
||||
if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') }}
|
||||
env:
|
||||
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
|
||||
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
|
||||
run: echo "${DOCKER_PASSWORD}" | docker login -u "${DOCKER_USERNAME}" --password-stdin docker.io
|
||||
|
||||
- name: Setup buildx
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y qemu-user-static
|
||||
docker buildx create --use
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v1
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
id: buildx
|
||||
uses: docker/setup-buildx-action@v1
|
||||
with:
|
||||
install: true
|
||||
|
||||
- name: Build Docker image
|
||||
env:
|
||||
PLATFORMS: linux/amd64,linux/arm64/v8,linux/arm/v7
|
||||
DOCKER_REPOSITORY: thelounge/thelounge
|
||||
run: |
|
||||
TAG="$(git rev-parse --short HEAD)"
|
||||
EXTRA_ARG=()
|
||||
# Only push on regular push (!= pull_request)
|
||||
if [ "${GITHUB_EVENT_NAME}" = "push" ] && grep -q "^refs/tags/" <<< "${GITHUB_REF}"; then
|
||||
EXTRA_ARG+=("--push")
|
||||
VERSION="$(git describe --exact-match --tags)"
|
||||
TAG="${VERSION}"
|
||||
MAJOR_TAG="$(echo "$VERSION" | sed -nre 's/^([0-9]+).*/\1/p')"
|
||||
LATEST_TAG="latest"
|
||||
if grep -q "^alpine/" <<< "${{ matrix.dockerfile }}"; then
|
||||
TAG="${TAG}-alpine"
|
||||
MAJOR_TAG="${MAJOR_TAG}-alpine"
|
||||
LATEST_TAG="alpine"
|
||||
fi
|
||||
# If not a pre-release push LATEST_TAG & MAJOR_TAG
|
||||
if grep -qE "^[0-9]*\.[0-9]*\.[0-9]*$" <<< "${VERSION}"; then
|
||||
EXTRA_ARG+=("--tag" "${DOCKER_REPOSITORY}:${LATEST_TAG}")
|
||||
EXTRA_ARG+=("--tag" "${DOCKER_REPOSITORY}:${MAJOR_TAG}")
|
||||
fi
|
||||
fi
|
||||
docker buildx build \
|
||||
--platform "${PLATFORMS}" \
|
||||
--tag "${DOCKER_REPOSITORY}:${TAG}" \
|
||||
"${EXTRA_ARG[@]}" \
|
||||
--file "${{ matrix.dockerfile }}" \
|
||||
.
|
||||
DOCKERFILE: ${{ matrix.dockerfile }}
|
||||
run: ./scripts/build-and-push.sh
|
||||
|
|
35
.github/workflows/docker-image-test.yml
vendored
35
.github/workflows/docker-image-test.yml
vendored
|
@ -7,32 +7,53 @@ jobs:
|
|||
name: Build
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
platform: [linux/amd64, linux/arm64/v8, linux/arm/v7]
|
||||
dockerfile: [Dockerfile, alpine/Dockerfile]
|
||||
steps:
|
||||
- name: Set env
|
||||
run: echo "mount_dir=$(mktemp -d)" >> $GITHUB_ENV
|
||||
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v1
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v1
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
id: buildx
|
||||
uses: docker/setup-buildx-action@v1
|
||||
with:
|
||||
install: true
|
||||
|
||||
- name: Build Docker image
|
||||
run: docker build -t thelounge -f ${{ matrix.dockerfile }} .
|
||||
run: docker build --platform ${{ matrix.platform }} --load -t thelounge -f ${{ matrix.dockerfile }} .
|
||||
|
||||
- name: Start Docker container
|
||||
run: docker run --user "$UID" -v "${mount_dir}:/var/opt/thelounge" -d -p 9001:9000 --name thelounge thelounge
|
||||
run: docker run --platform ${{ matrix.platform }} --user "$UID" -v "${mount_dir}:/var/opt/thelounge" -d -p 9001:9000 --name thelounge thelounge
|
||||
|
||||
- name: Check TheLounge version
|
||||
run: docker exec thelounge thelounge --version | grep --color=never -E "^v[0-9]\.[0-9]\.[0-9]" | cut -c 2- | grep -f /dev/stdin ${{ matrix.dockerfile }}
|
||||
|
||||
- name: Wait for server to (hopefully) start
|
||||
run: sleep 3
|
||||
|
||||
- name: Check HTML output
|
||||
run: curl -sL localhost:9001 | grep "<title>The Lounge</title>"
|
||||
run: |
|
||||
# Retry Wait for server to start.
|
||||
for i in {1..10}; do
|
||||
(curl -sL localhost:9001 | grep "<title>The Lounge</title>") && s=0 && break || s=$? && sleep 1;
|
||||
done
|
||||
exit $s
|
||||
|
||||
- name: Check for no ERROR logs
|
||||
run: docker logs thelounge | grep "\[ERROR\]" && exit 1 || exit 0
|
||||
|
||||
- name: Check for config.js to be created in the mounted host system directory
|
||||
run: stat "${mount_dir}/config.js"
|
||||
|
||||
- name: Container context
|
||||
if: always()
|
||||
run: docker exec thelounge uname -a
|
||||
|
||||
- name: Logs
|
||||
if: always()
|
||||
run: docker logs thelounge
|
||||
|
|
10
Dockerfile
10
Dockerfile
|
@ -16,5 +16,11 @@ COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
|
|||
|
||||
# Install thelounge.
|
||||
ARG THELOUNGE_VERSION=4.3.0
|
||||
RUN yarn --non-interactive --frozen-lockfile global add thelounge@${THELOUNGE_VERSION} && \
|
||||
yarn --non-interactive cache clean
|
||||
RUN apt update && apt install -y python2 g++ make && \
|
||||
ln -s $(which python2) /usr/bin/python && \
|
||||
yarn --non-interactive --frozen-lockfile global add thelounge@${THELOUNGE_VERSION} && \
|
||||
yarn --non-interactive cache clean && \
|
||||
apt remove -y python2 g++ make && \
|
||||
apt autoremove -y && \
|
||||
rm -rf /var/lib/apt/lists/* && \
|
||||
rm -f /usr/bin/python
|
||||
|
|
|
@ -16,7 +16,7 @@ COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
|
|||
|
||||
# Install thelounge.
|
||||
ARG THELOUNGE_VERSION=4.3.0
|
||||
RUN apk --update --no-cache add python3 build-base && \
|
||||
RUN apk --update --no-cache add python2 build-base && \
|
||||
yarn --non-interactive --frozen-lockfile global add thelounge@${THELOUNGE_VERSION} && \
|
||||
yarn --non-interactive cache clean && \
|
||||
apk del python3 build-base
|
||||
apk del python2 build-base
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
if [ "$1" = "thelounge" ] && [ "$(id -u)" = '0' ]; then
|
||||
find "${THELOUNGE_HOME}" \! -user node -exec chown node '{}' +
|
||||
exec su node -c "$*"
|
||||
fi
|
||||
|
||||
exec "$@"
|
29
scripts/build-and-push.sh
Executable file
29
scripts/build-and-push.sh
Executable file
|
@ -0,0 +1,29 @@
|
|||
#!/usr/bin/env bash
|
||||
# Script executed by GitHub actions.
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
VERSION="$GITHUB_REF"
|
||||
TAG="$VERSION"
|
||||
MAJOR_TAG="$(sed -nre 's/^([0-9]+).*/\1/p' <<< "$VERSION")"
|
||||
LATEST_TAG="latest"
|
||||
|
||||
if grep -q "^alpine/" <<< "${DOCKERFILE}"; then
|
||||
TAG="${VERSION}-alpine"
|
||||
MAJOR_TAG="${MAJOR_TAG}-alpine"
|
||||
LATEST_TAG="alpine"
|
||||
fi
|
||||
|
||||
# If not a pre-release push LATEST_TAG & MAJOR_TAG
|
||||
if grep -qE "^[0-9]*\.[0-9]*\.[0-9]*$" <<< "${VERSION}"; then
|
||||
EXTRA_ARG+=("--tag" "${DOCKER_REPOSITORY}:${LATEST_TAG}")
|
||||
EXTRA_ARG+=("--tag" "${DOCKER_REPOSITORY}:${MAJOR_TAG}")
|
||||
fi
|
||||
|
||||
docker buildx build \
|
||||
--push \
|
||||
--platform "${PLATFORMS}" \
|
||||
--tag "${DOCKER_REPOSITORY}:${TAG}" \
|
||||
"${EXTRA_ARG[@]}" \
|
||||
--file "${DOCKERFILE}" \
|
||||
.
|
Loading…
Reference in a new issue