diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..f742309 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,55 @@ +name: instances.invidio.us CI + +on: + push: + branches: + - "master" + pull_request: + branches: "*" + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Install Crystal + uses: oprypin/install-crystal@v1.3.0 + + - name: Cache Shards + uses: actions/cache@v2 + with: + path: ./lib + key: shards-${{ hashFiles('shard.lock') }} + + - name: Install Shards + run: | + if ! shards check; then + shards install + fi + + - name: Run lint + run: | + if ! crystal tool format --check; then + crystal tool format + git diff + exit 1 + fi + + - name: Build + run: crystal build --warnings all --error-on-warnings --error-trace src/instances.cr + + build-docker: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Build Docker + run: docker-compose up -d + + - name: Test Docker + run: curl -Isf http://localhost:3000 diff --git a/.gitignore b/.gitignore index 6145751..5256417 100644 --- a/.gitignore +++ b/.gitignore @@ -7,5 +7,4 @@ /.vscode/ /instances /sentry -shard.lock *.dwarf diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index bc4c4ca..0000000 --- a/.travis.yml +++ /dev/null @@ -1,5 +0,0 @@ -language: crystal -# Uncomment the following if you'd like Travis to run specs and check code formatting -# script: -# - crystal spec -# - crystal tool format --check diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..b4c3c5a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,18 @@ +FROM crystallang/crystal:0.35.1-alpine AS builder +WORKDIR /app +COPY ./shard.yml ./shard.yml +RUN shards install +COPY ./src/ ./src/ +RUN crystal build ./src/instances.cr --release + +FROM alpine:latest +RUN apk add --no-cache gc pcre libgcc +WORKDIR /app +RUN addgroup -g 1000 -S invidious && \ + adduser -u 1000 -S invidious -G invidious +COPY ./assets/ ./assets/ +COPY --from=builder /app/instances . + +EXPOSE 3000 +USER invidious +CMD ["/app/instances"] diff --git a/README.md b/README.md index 18c2003..440552c 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ # [instances.invidio.us](https://instances.invidio.us) -Status page for [Invidious](https://github.com/iv-org/invidious) instances, sourced from [here](https://github.com/iv-org/documentation/blob/master/Invidious-Instances.md). +[![Build Status](https://github.com/iv-org/instances.invidio.us/workflows/instances.invidio.us%20CI/badge.svg)](https://github.com/iv-org/instances.invidio.us/actions) + +Status page for [Invidious](https://github.com/iv-org/invidious) instances, sourced from [the documentation](https://github.com/iv-org/documentation/blob/master/Invidious-Instances.md). ## Installation diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..83e664a --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,7 @@ +version: '3' +services: + instances: + build: . + restart: unless-stopped + ports: + - "127.0.0.1:3000:3000" diff --git a/shard.lock b/shard.lock new file mode 100644 index 0000000..7bc1fe3 --- /dev/null +++ b/shard.lock @@ -0,0 +1,18 @@ +version: 2.0 +shards: + exception_page: + git: https://github.com/crystal-loot/exception_page.git + version: 0.1.4 + + kemal: + git: https://github.com/kemalcr/kemal.git + version: 0.27.0+git.commit.bf9f627ac789d2ebe573629904f02beb9e4089d5 + + kilt: + git: https://github.com/jeromegn/kilt.git + version: 0.4.0 + + radix: + git: https://github.com/luislavena/radix.git + version: 0.3.9 +