diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml
index 296bc0d..dc7c682 100644
--- a/.github/workflows/master.yml
+++ b/.github/workflows/master.yml
@@ -42,4 +42,67 @@ jobs:
uses: sonarsource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
\ No newline at end of file
+ SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
+
+ docker:
+ name: Publish Docker Image
+ needs: [ build-test ]
+ runs-on: ubuntu-latest
+ if: success() && github.ref == 'refs/heads/master'
+
+ outputs:
+ digest: ${{ steps.docker_build.outputs.digest }}
+
+ steps:
+ - name: Set up QEMU
+ uses: docker/setup-qemu-action@v2
+
+ - name: Set up Docker Buildx
+ uses: docker/setup-buildx-action@v2
+
+ - name: Login to DockerHub
+ uses: docker/login-action@v2
+ with:
+ username: ${{ secrets.DOCKERHUB_USERNAME }}
+ password: ${{ secrets.DOCKERHUB_TOKEN }}
+
+ - name: Build and push
+ id: docker_build
+ uses: docker/build-push-action@v3
+ with:
+ push: true
+ platforms: linux/amd64
+ tags: trackerforce/switcher-searchdocs:latest
+
+ update-kustomize:
+ name: Deploy
+ needs: [ docker ]
+ runs-on: ubuntu-latest
+
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v3
+ with:
+ ref: 'master'
+
+ - name: Checkout Kustomize
+ uses: actions/checkout@v3
+ with:
+ token: ${{ secrets.ARGOCD_PAT }}
+ repository: switcherapi/switcher-deployment
+ ref: master
+
+ - name: Set Image
+ uses: stefanprodan/kube-tools@v1
+ with:
+ kubectl: 1.24.0
+ kustomize: 4.5.4
+ command: |
+ cd switcher-searchdocs/base
+ echo RELEASE_TIME=`date` > environment-properties.env
+ kustomize edit set image trackerforce/switcher-searchdocs:latest=trackerforce/switcher-searchdocs@${{ needs.docker.outputs.digest }}
+ git config --global user.email "${{ github.actor }}@users.noreply.github.com"
+ git config --global user.name "${{ github.actor }}"
+ git add .
+ git commit -m "[argocd] switcher-searchdocs: ${{ needs.docker.outputs.digest }}"
+ git push
\ No newline at end of file
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
new file mode 100644
index 0000000..0114053
--- /dev/null
+++ b/.github/workflows/release.yml
@@ -0,0 +1,67 @@
+name: Release CI
+
+on:
+ release:
+ types: [ created ]
+
+jobs:
+ build-test:
+ name: Build & Test
+ runs-on: ubuntu-latest
+ if: "! contains(toJSON(github.event.commits.*.message), '[skip ci]')"
+
+ steps:
+ - name: Git checkout
+ uses: actions/checkout@v3
+ with:
+ fetch-depth: 0
+
+ - name: Setup Deno v1.36.1
+ uses: denoland/setup-deno@v1
+ with:
+ deno-version: v1.36.1
+
+ - name: Verify formatting
+ run: deno task fmt
+
+ - name: Run linter
+ run: deno lint
+
+ - name: Run tests and coverage
+ run: deno task test
+
+ docker:
+ name: Publish Docker Image
+ needs: [ build-test ]
+ runs-on: ubuntu-latest
+
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@v3
+
+ - name: Docker meta
+ id: meta
+ uses: docker/metadata-action@v4
+ with:
+ images: trackerforce/switcher-searchdocs
+
+ - name: Set up QEMU
+ uses: docker/setup-qemu-action@v2
+
+ - name: Set up Docker Buildx
+ uses: docker/setup-buildx-action@v2
+
+ - name: Login to DockerHub
+ uses: docker/login-action@v2
+ with:
+ username: ${{ secrets.DOCKERHUB_USERNAME }}
+ password: ${{ secrets.DOCKERHUB_TOKEN }}
+
+ - name: Build and push
+ uses: docker/build-push-action@v3
+ with:
+ context: .
+ push: true
+ platforms: linux/amd64
+ tags: ${{ steps.meta.outputs.tags }}
+ labels: ${{ steps.meta.outputs.labels }}
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..6494a45
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,16 @@
+FROM denoland/deno:alpine-1.37.0
+
+ENV APP_HOME=/home/app
+WORKDIR $APP_HOME
+
+COPY /src/deps.ts $APP_HOME
+
+RUN deno cache deps.ts
+
+COPY /src .
+
+RUN addgroup -S app && \
+ adduser -S app -G app && \
+ chown -R app:app $APP_HOME /deno-dir
+
+USER app
\ No newline at end of file
diff --git a/README.md b/README.md
index 9c4c1ad..da62cdb 100644
--- a/README.md
+++ b/README.md
@@ -9,6 +9,7 @@ A remote document search engine that uses Skimming for Deno
[](https://github.com/switcherapi/switcher-searchdocs/actions/workflows/master.yml)
[](https://sonarcloud.io/dashboard?id=switcherapi_switcher-searchdocs)
+[](https://hub.docker.com/r/trackerforce/switcher-searchdocs)
[](https://opensource.org/licenses/MIT)
[](https://switcher-hq.slack.com/)
diff --git a/docker-compose.yml b/docker-compose.yml
new file mode 100644
index 0000000..45c4e6f
--- /dev/null
+++ b/docker-compose.yml
@@ -0,0 +1,37 @@
+version: '3.8'
+
+# TLS Enabled
+# volumes:
+# switcherapi-tls:
+# driver: local
+# driver_opts:
+# o: bind
+# type: none
+# device: "/data/certs"
+
+services:
+ app:
+ image: trackerforce/switcher-searchdocs:latest
+ container_name: switcher-searchdocs
+ command: ["run", "--allow-net", "--allow-env", "--allow-read", "index.ts"]
+ ports:
+ - 4000:4000
+ environment:
+ - APP_PORT=4000
+ - RELEASE_TIME=today
+ # - SSL_CERT=/etc/ssl/certs/tls.crt
+ # - SSL_KEY=/etc/ssl/certs/tls.pem
+
+ - APP_RATE_LIMIT=10
+ - APP_RATE_LIMIT_WINDOW=3000
+ - LOG_LEVEL=INFO # DEBUG, INFO, ERROR
+
+ # Skimming Global Settings
+ - APP_URL=https://raw.githubusercontent.com/petruki/skimming/master/
+ - APP_FILES=README.md
+ - APP_CACHE_EXP_DURATION=5
+ - APP_CACHE_SIZE=100
+ - APP_ALLOW_URL=false
+ - APP_ALLOW_FILES=false
+ # volumes:
+ # - switcherapi-tls:/etc/ssl/certs