diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..05356c09 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,8 @@ +.github/ +.husky/ +.idea/ +.vscode/ + +node_modules/ +dist/ +files/ diff --git a/.github/workflows/publish-image.yml b/.github/workflows/publish-image.yml new file mode 100644 index 00000000..ed1ff734 --- /dev/null +++ b/.github/workflows/publish-image.yml @@ -0,0 +1,50 @@ +name: Publish Image + +on: + release: + types: [published] + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + build-and-push-image: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + attestations: write + id-token: write + steps: + - name: Checkout repository + uses: actions/checkout@v5 + + - name: Log in to the Container registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Build and push Docker image + id: push + uses: docker/build-push-action@v6 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + + - name: Generate artifact attestation + uses: actions/attest-build-provenance@v3 + with: + subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}} + subject-digest: ${{ steps.push.outputs.digest }} + push-to-registry: true diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..611a009e --- /dev/null +++ b/Dockerfile @@ -0,0 +1,75 @@ +ARG DEBIAN_CODE=trixie +ARG NODE_VERSION=24 +ARG PYTHON_VERSION=3.13 +ARG USER_NAME=spacebar +ARG USER_GROUP=$USER_NAME +ARG USER_UID=1000 +ARG USER_GID=1000 +ARG BASEDIR=/spacebar + + +FROM python:${PYTHON_VERSION}-slim-${DEBIAN_CODE} AS base_python + + +FROM node:${NODE_VERSION}-${DEBIAN_CODE}-slim AS base + +COPY --from=base_python /usr/local/bin/python* /usr/local/bin/ +COPY --from=base_python /usr/local/bin/pip* /usr/local/bin/ +COPY --from=base_python /usr/local/lib/python* /usr/local/lib/ +COPY --from=base_python /usr/local/lib/libpython* /usr/local/lib/ + + +FROM base AS builder + +ARG BRANCH + +WORKDIR /build + +RUN apt-get update && \ + apt-get install -y --no-install-recommends build-essential pkg-config && \ + rm -rf /var/lib/apt/lists/* + +WORKDIR /build/server + +COPY . . + +RUN npm i \ + && npm run setup + + +FROM base AS final + +ARG USER_NAME +ARG USER_GROUP +ARG USER_UID +ARG USER_GID +ARG BASEDIR + +RUN mkdir -p "${BASEDIR}/server" \ + && chown -R "${USER_UID}:${USER_GID}" "${BASEDIR}" + +RUN deluser node 2>/dev/null || true \ + && delgroup node 2>/dev/null || true \ + && rm -fr /home/node 2>/dev/null || true \ + && addgroup --gid "$USER_GID" "$USER_GROUP" \ + && adduser \ + --disabled-password \ + --gecos "" \ + --uid "$USER_UID" \ + --gid "$USER_GID" \ + --no-create-home \ + "$USER_NAME" + +USER ${USER_NAME} + +#@todo: only bring what we need +COPY --chown=${USER_NAME}:${USER_GROUP} --from=builder /build/server "${BASEDIR}/server" + +ENV PORT="3001" +ENV CONFIG_PATH="${BASEDIR}/config.json" +ENV DATABASE="${BASEDIR}/database.db" + +WORKDIR "${BASEDIR}/server" + +ENTRYPOINT [ "npm", "run" ] +CMD [ "start" ] diff --git a/assets/openapi.json b/assets/openapi.json index d2bc69f3..0aa58c79 100644 Binary files a/assets/openapi.json and b/assets/openapi.json differ diff --git a/assets/schemas.json b/assets/schemas.json index 5a8e17fd..6122ddc9 100644 Binary files a/assets/schemas.json and b/assets/schemas.json differ diff --git a/src/schemas/api/guilds/Sticker.ts b/src/schemas/api/guilds/Sticker.ts index 89b11ccf..b02e1e21 100644 --- a/src/schemas/api/guilds/Sticker.ts +++ b/src/schemas/api/guilds/Sticker.ts @@ -4,8 +4,8 @@ export enum StickerType { } export enum StickerFormatType { - GIF = 0, // gif is a custom format type and not in discord spec PNG = 1, APNG = 2, LOTTIE = 3, + GIF = 4, } diff --git a/src/util/entities/ApplicationCommand.ts b/src/util/entities/ApplicationCommand.ts index 82436f7a..8ec154f8 100644 --- a/src/util/entities/ApplicationCommand.ts +++ b/src/util/entities/ApplicationCommand.ts @@ -53,7 +53,7 @@ export class ApplicationCommand extends BaseClass { @Column({ nullable: true, type: "simple-json" }) description_localizations?: Record; - @Column({ type: "simple-json", default: [] }) + @Column({ type: "simple-json", default: "[]" }) options: ApplicationCommandOption[]; @Column({ nullable: true, type: String }) diff --git a/src/util/migration/postgres/1762611552514-fix-gif-stickers-format_type.ts b/src/util/migration/postgres/1762611552514-fix-gif-stickers-format_type.ts new file mode 100644 index 00000000..47de7506 --- /dev/null +++ b/src/util/migration/postgres/1762611552514-fix-gif-stickers-format_type.ts @@ -0,0 +1,11 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class FixGifStickersFormatType1762611552514 implements MigrationInterface { + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`UPDATE "stickers" SET "format_type" = 4 WHERE "format_type" = 0;`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`UPDATE "stickers" SET "format_type" = 0 WHERE "format_type" = 4;`); + } +}