From abf4aac541e4b26c4505ad17c2e8ae3c7885a9d8 Mon Sep 17 00:00:00 2001 From: Mihaly Lengyel Date: Mon, 17 Feb 2025 10:43:24 +0100 Subject: [PATCH] backport: ci changes from webauthn version --- .github/PULL_REQUEST_TEMPLATE.md | 1 - .github/helpers/Dockerfile | 74 ++++++++++++++++++++++++ .github/workflows/publish-dev-docker.yml | 42 ++++++++++++++ 3 files changed, 116 insertions(+), 1 deletion(-) create mode 100644 .github/helpers/Dockerfile create mode 100644 .github/workflows/publish-dev-docker.yml diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index edc898ed2..fa8708570 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -37,7 +37,6 @@ highlighting the necessary changes) - If no such branch exists, then create one from the latest released branch. - [ ] If added a foreign key constraint on `app_id_to_user_id` table, make sure to delete from this table when deleting the user as well if `deleteUserIdMappingToo` is false. -- [ ] If added a new recipe, then make sure to update the bulk import API to include the new recipe. ## Remaining TODOs for this PR diff --git a/.github/helpers/Dockerfile b/.github/helpers/Dockerfile new file mode 100644 index 000000000..e832d63cb --- /dev/null +++ b/.github/helpers/Dockerfile @@ -0,0 +1,74 @@ +FROM ubuntu:22.04 AS tmp + +RUN apt-get update && apt-get upgrade -y +RUN apt-get install build-essential -y +RUN apt-get install -y git-core wget unzip jq curl + +# Install OpenJDK 15.0.1 +RUN wget https://download.java.net/java/GA/jdk15.0.1/51f4f36ad4ef43e39d0dfdbaf6549e32/9/GPL/openjdk-15.0.1_linux-x64_bin.tar.gz +RUN mkdir -p /usr/java +RUN mv openjdk-15.0.1_linux-x64_bin.tar.gz /usr/java +RUN cd /usr/java && tar -xzvf openjdk-15.0.1_linux-x64_bin.tar.gz + +RUN echo 'JAVA_HOME=/usr/java/jdk-15.0.1' >> /etc/profile +RUN echo 'PATH=$PATH:$HOME/bin:$JAVA_HOME/bin' >> /etc/profile +RUN echo 'export JAVA_HOME' >> /etc/profile +RUN echo 'export JRE_HOME' >> /etc/profile +RUN echo 'export PATH' >> /etc/profile + +RUN update-alternatives --install "/usr/bin/java" "java" "/usr/java/jdk-15.0.1/bin/java" 1 +RUN update-alternatives --install "/usr/bin/javac" "javac" "/usr/java/jdk-15.0.1/bin/javac" 1 + +RUN wget -O docker-entrypoint.sh https://raw.githubusercontent.com/supertokens/supertokens-docker-postgresql/master/docker-entrypoint.sh + +# RUN wget https://services.gradle.org/distributions/gradle-7.0-all.zip +# RUN unzip gradle-7.0-all.zip +# ENV GRADLE_HOME=/gradle-7.0 +# ENV PATH=$PATH:$GRADLE_HOME/bin + +RUN git clone https://github.com/supertokens/supertokens-root.git +WORKDIR /supertokens-root +COPY ./pluginInterfaceSupported.json pluginInterfaceSupported.json +RUN git clone --single-branch --branch "$(cat pluginInterfaceSupported.json | jq '.versions[-1]' | tr -d '"')" "https://github.com/supertokens/supertokens-plugin-interface.git" +RUN mkdir -p supertokens-core +COPY ./ supertokens-core +RUN echo "org.gradle.vfs.watch=false" >> ./gradle.properties +RUN ./loadModules +RUN ./utils/setupTestEnv --cicd + + +FROM debian:bookworm-slim +RUN groupadd supertokens && useradd -m -s /bin/bash -g supertokens supertokens +RUN apt-get update && apt-get install -y --no-install-recommends gnupg dirmngr curl unzip && rm -rf /var/lib/apt/lists/* +ENV GOSU_VERSION=1.7 +RUN set -x \ + && apt-get update && apt-get install -y --no-install-recommends ca-certificates wget && rm -rf /var/lib/apt/lists/* \ + && wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$(dpkg --print-architecture)" \ + && wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$(dpkg --print-architecture).asc" \ + && export GNUPGHOME="$(mktemp -d)" \ + && gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4 \ + && gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu \ + && gpgconf --kill all \ + && rm -rf "$GNUPGHOME" /usr/local/bin/gosu.asc \ + && chmod +x /usr/local/bin/gosu \ + && wget -O jre.zip "https://raw.githubusercontent.com/supertokens/jre/master/jre-15.0.1-linux.zip" \ + && mkdir -p /usr/lib/supertokens/jre \ + && unzip jre.zip \ + && mv jre-*/* /usr/lib/supertokens/jre \ + && apt-get purge -y --auto-remove ca-certificates wget unzip \ + && rm -rf jre.zip +COPY --from=tmp --chown=supertokens /supertokens-root/core /usr/lib/supertokens/core +COPY --from=tmp --chown=supertokens /supertokens-root/plugin-interface /usr/lib/supertokens/plugin-interface +COPY --from=tmp --chown=supertokens /supertokens-root/ee /usr/lib/supertokens/ee +COPY --from=tmp --chown=supertokens /supertokens-root/temp/config.yaml /usr/lib/supertokens/config.yaml +COPY --from=tmp --chown=supertokens /supertokens-root/version.yaml /usr/lib/supertokens/version.yaml +COPY --from=tmp --chown=supertokens /docker-entrypoint.sh /usr/local/bin/ +RUN mkdir -p /lib/supertokens +RUN chown -R supertokens:supertokens /lib/supertokens +RUN chmod +x /usr/local/bin/docker-entrypoint.sh +RUN echo "$(md5sum /usr/lib/supertokens/config.yaml | awk '{ print $1 }')" >> /CONFIG_HASH +RUN ln -s /usr/local/bin/docker-entrypoint.sh /entrypoint.sh # backwards compat +EXPOSE 3567 +USER "supertokens" +CMD ["/usr/lib/supertokens/jre/bin/java", "-classpath", "/usr/lib/supertokens/core/*:/usr/lib/supertokens/plugin-interface/*:/usr/lib/supertokens/ee/*", "io.supertokens.Main", "/usr/lib/supertokens", "DEV", "host=0.0.0.0", "test_mode"] +ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"] \ No newline at end of file diff --git a/.github/workflows/publish-dev-docker.yml b/.github/workflows/publish-dev-docker.yml new file mode 100644 index 000000000..2d3e63e28 --- /dev/null +++ b/.github/workflows/publish-dev-docker.yml @@ -0,0 +1,42 @@ +name: Publish Dev Docker Image +on: + push: + branches: + - "**" +jobs: + docker: + runs-on: ubuntu-latest + steps: + - name: set tag + id: set_tag + run: | + echo "TAG=${GITHUB_REF}" | sed 's/refs\/heads\///g' | sed 's/\//_/g' >> $GITHUB_OUTPUT + - + name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ vars.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - + name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + # - name: Build and export to Docker + # uses: docker/build-push-action@v6 + # with: + # load: true + # tags: ${{ env.TEST_TAG }} + + # - name: Test + # run: | + # docker run --rm ${{ env.TEST_TAG }} + + - name: Build and push + uses: docker/build-push-action@v6 + with: + push: true + tags: ${{ vars.DOCKERHUB_USERNAME }}/supertokens-core:dev-branch-${{ steps.set_tag.outputs.TAG }} + file: .github/helpers/Dockerfile