diff --git a/.github/workflows/build_and_push.yaml b/.github/workflows/build_and_push.yaml new file mode 100644 index 0000000..9c51b09 --- /dev/null +++ b/.github/workflows/build_and_push.yaml @@ -0,0 +1,58 @@ +name: Build Docker Image + +on: + push: + branches: + - main + tags: + - "v*" + +env: + RELEASE_VERSION: ${{ github.ref_name }} + +jobs: + build-and-publish: + name: Build and Publish Container + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Docker meta + id: meta + uses: docker/metadata-action@v4 + with: + # list of Docker images to use as base name for tags + images: | + ghcr.io/katharostech/linode-cli + + # generate Docker tags based on the following events/attributes + tags: | + type=schedule + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + type=sha + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push + uses: docker/build-push-action@v3 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..4911656 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,4 @@ +FROM alpine:latest +RUN apk add --no-cache pipx +RUN pipx install linode-cli +ENTRYPOINT ["sh"] diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..fdddb29 --- /dev/null +++ b/LICENSE @@ -0,0 +1,24 @@ +This is free and unencumbered software released into the public domain. + +Anyone is free to copy, modify, publish, use, compile, sell, or +distribute this software, either in source code form or as a compiled +binary, for any purpose, commercial or non-commercial, and by any +means. + +In jurisdictions that recognize copyright laws, the author or authors +of this software dedicate any and all copyright interest in the +software to the public domain. We make this dedication for the benefit +of the public at large and to the detriment of our heirs and +successors. We intend this dedication to be an overt act of +relinquishment in perpetuity of all present and future rights to this +software under copyright law. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +For more information, please refer to diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh new file mode 100644 index 0000000..aea9831 --- /dev/null +++ b/docker-entrypoint.sh @@ -0,0 +1,64 @@ +#!/bin/sh + +set -e + +# Make sure the database exists +touch /data/ooye.db + +cat << EOF > config.js +module.exports = { + discordToken: "${DISCORD_TOKEN}" +} +EOF + +admin_invite_line="" +admin_invite_empty="" + +if [ -n "${ADMIN_INVITE}" ]; then + admin_invite_line="- '${ADMIN_INVITE}'" +else + admin_invite_empty="[]" +fi + +cat << EOF > registration.yaml +id: de8c56117637cb5d9f4ac216f612dc2adb1de4c09ae8d13553f28c33a28147c7 +hs_token: ${HS_TOKEN} +as_token: ${AS_TOKEN} +url: ${URL} +sender_localpart: ${NAMESPACE_PREFIX}_bridge_bot +protocols: + - discord +namespaces: + users: + - exclusive: true + regex: '@${NAMESPACE_PREFIX}.*' + aliases: + - exclusive: true + regex: '#${NAMESPACE_PREFIX}.*' +rate_limited: false +ooye: + namespace_prefix: ${NAMESPACE_PREFIX} + max_file_size: 5000000 + server_name: ${SERVER_NAME} + server_origin: ${SERVER_ORIGIN} + content_length_workaround: ${CONTENT_LENGTH_WORKAROUND} + invite: ${admin_invite_empty} + ${admin_invite_line} +EOF + +echo "Here is your registration YAML:" +echo "" +cat registration.yaml +echo "" + +echo "Setting up / seeding database if necessary" + +emoji_arg="" +if [ -n "${EMOJI_GUILD}" ]; then + emoji_arg="--emoji-guild=${EMOJI_GUILD}" +fi + +node scripts/seed.js $emoji_arg + +echo "Starting server" +exec node start.js