diff --git a/.github/workflows/dev-image.yml b/.github/workflows/dev-image.yml new file mode 100644 index 000000000..a41929660 --- /dev/null +++ b/.github/workflows/dev-image.yml @@ -0,0 +1,158 @@ +name: Create Dev-Image + +on: + pull_request_target: + branches: + - main + - dev + types: + - opened + - synchronize + - reopened + +concurrency: + group: pr-${{ github.event.pull_request.number }} + cancel-in-progress: true + +env: + TAG_URL: https://hub.docker.com/r/${{ vars.DOCKER_HUB_REPO }}/tags + TAG: ${{ vars.DOCKER_HUB_REPO }}:dev-pr${{ github.event.pull_request.number }} + TAG_PG: ${{ vars.DOCKER_HUB_REPO }}:postgresql-dev-pr${{ github.event.pull_request.number }} + +jobs: + build-w: + if: ${{ github.event.pull_request.head.repo.full_name != github.repository }} + runs-on: ubuntu-latest + environment: build-dev + + steps: + - name: Checkout PR code + uses: actions/checkout@v4 + with: + ref: refs/pull/${{github.event.pull_request.number}}/merge + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_HUB_USERNAME }} + password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build and push Docker image SQLITE + uses: docker/build-push-action@v6 + with: + context: . + platforms: linux/amd64 + push: true + tags: ${{ env.TAG }} + build-args: DATABASE=sqlite + cache-from: type=registry,ref=${{ vars.DOCKER_HUB_REPO }}:buildcache + cache-to: type=registry,ref=${{ vars.DOCKER_HUB_REPO }}:buildcache,mode=max + + - name: Build and push Docker image PG + uses: docker/build-push-action@v6 + with: + context: . + platforms: linux/amd64 + push: true + tags: ${{ env.TAG_PG }} + build-args: DATABASE=pg + cache-from: type=registry,ref=${{ vars.DOCKER_HUB_REPO }}:buildcache-pg + cache-to: type=registry,ref=${{ vars.DOCKER_HUB_REPO }}:buildcache-pg,mode=max + + - uses: actions/github-script@v8 + with: + script: | + const repoUrl = process.env.TAG_URL; + const tag = process.env.TAG; + const tagPg = process.env.TAG_PG; + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: `> [!WARNING] + > This image may contain unchecked and breaking changes. Only use on own risk. + + 👋 Thanks for your PR! + Dev images for this PR are now available on [docker hub](${repoUrl}): + + **SQLITE Image:** + \`\`\` + ${tag} + \`\`\` + + **Postgresql Image:** + \`\`\` + ${tagPg} + \`\`\`` + }) + build-wo: + if: ${{ github.event.pull_request.head.repo.full_name == github.repository }} + runs-on: ubuntu-latest + + steps: + - name: Checkout PR code + uses: actions/checkout@v4 + with: + ref: refs/pull/${{github.event.pull_request.number}}/merge + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_HUB_USERNAME }} + password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build and push Docker image SQLITE + uses: docker/build-push-action@v6 + with: + context: . + platforms: linux/amd64 + push: true + tags: ${{ env.TAG }} + build-args: DATABASE=sqlite + cache-from: type=registry,ref=${{ vars.DOCKER_HUB_REPO }}:buildcache + cache-to: type=registry,ref=${{ vars.DOCKER_HUB_REPO }}:buildcache,mode=max + + - name: Build and push Docker image PG + uses: docker/build-push-action@v6 + with: + context: . + platforms: linux/amd64 + push: true + tags: ${{ env.TAG_PG }} + build-args: DATABASE=pg + cache-from: type=registry,ref=${{ vars.DOCKER_HUB_REPO }}:buildcache-pg + cache-to: type=registry,ref=${{ vars.DOCKER_HUB_REPO }}:buildcache-pg,mode=max + + - uses: actions/github-script@v8 + with: + script: | + const repoUrl = process.env.TAG_URL; + const tag = process.env.TAG; + const tagPg = process.env.TAG_PG; + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: `> [!WARNING] + > This image may contain unchecked and breaking changes. Only use on own risk. + + 👋 Thanks for your PR! + Dev images for this PR are now available on [docker hub](${repoUrl}): + + **SQLITE Image:** + \`\`\` + ${tag} + \`\`\` + + **Postgresql Image:** + \`\`\` + ${tagPg} + \`\`\`` + }) + diff --git a/Makefile b/Makefile index ae31f50c6..38bcec5d1 100644 --- a/Makefile +++ b/Makefile @@ -330,3 +330,17 @@ test: clean: docker rmi pangolin + +test-local: + cp config/config.example.yml config/config.yml + npm run set:oss + npm run set:sqlite + npm run db:sqlite:generate + npm run db:sqlite:push + - npx tsc --noEmit + - docker build --build-arg DATABASE=pg -t fosrl/pangolin:postgresql-latest . + - docker build --build-arg DATABASE=sqlite -t fosrl/pangolin:latest . + npm run set:saas + - npx tsc --noEmit + - docker build --build-arg DATABASE=pg -t fosrl/pangolin:postgresql-saas-latest . + - docker build --build-arg DATABASE=sqlite -t fosrl/pangolin:saas-latest . diff --git a/package-lock.json b/package-lock.json index 76e3e5c08..a8b7f0abf 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13952,6 +13952,7 @@ "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.32.0.tgz", "integrity": "sha512-whOE1HFo/qJDyX4SnXzP4N6zOWn79WhnCUY/iDR0mPfQZO8wcYE4JClzI2oZrhBnnMUCBCHZhO6VQyoBU95mZA==", "license": "MIT", + "peer": true, "dependencies": { "@rtsao/scc": "^1.1.0", "array-includes": "^3.1.9", @@ -20125,9 +20126,9 @@ } }, "node_modules/qs": { - "version": "6.14.0", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.14.0.tgz", - "integrity": "sha512-YWWTjgABSKcvs/nWBi9PycY/JiPJqOD4JA6o9Sej2AtvSGarXxKC3OQSk4pAarbdQlKAh5D4FCQkJNkW+GAn3w==", + "version": "6.14.1", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.14.1.tgz", + "integrity": "sha512-4EK3+xJl8Ts67nLYNwqw/dsFVnCf+qR7RgXSK9jEEm9unao3njwMDdmsdvoKBKHzxd7tCYz5e5M+SnMjdtXGQQ==", "license": "BSD-3-Clause", "dependencies": { "side-channel": "^1.1.0" @@ -20199,26 +20200,6 @@ "node": ">= 0.10" } }, - "node_modules/raw-body/node_modules/http-errors": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.1.tgz", - "integrity": "sha512-4FbRdAX+bSdmo4AUFuS0WNiPz8NgFt+r8ThgNWmlrjQjt1Q7ZR9+zTlce2859x4KSXrwIsaeTqDoKQmtP8pLmQ==", - "license": "MIT", - "dependencies": { - "depd": "~2.0.0", - "inherits": "~2.0.4", - "setprototypeof": "~1.2.0", - "statuses": "~2.0.2", - "toidentifier": "~1.0.1" - }, - "engines": { - "node": ">= 0.8" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/express" - } - }, "node_modules/raw-body/node_modules/iconv-lite": { "version": "0.7.0", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.7.0.tgz", diff --git a/server/private/routers/hybrid.ts b/server/private/routers/hybrid.ts index a398dfe68..3e5d76fea 100644 --- a/server/private/routers/hybrid.ts +++ b/server/private/routers/hybrid.ts @@ -1263,7 +1263,7 @@ hybridRouter.post( ); const geoIpLookupParamsSchema = z.object({ - ip: z.union([z.ipv4(), z.ipv6()]) + ip: z.string().ip() }); hybridRouter.get( "/geoip/:ip",