From 1aa1b7f8a31b88bf26b83d85424a0cbf38344952 Mon Sep 17 00:00:00 2001 From: j2gg0s Date: Fri, 22 Nov 2024 13:42:19 +0800 Subject: [PATCH] ci: use custom mssql image in workflow to slove tls error --- .github/workflows/build.yml | 4 ++-- .github/workflows/mssql-container.yml | 29 +++++++++++++++++++++++++ internal/dbtest/mssql-docker/Dockerfile | 11 ++++++---- internal/dbtest/mssql-docker/mssql.conf | 4 ++-- 4 files changed, 40 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/mssql-container.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ce4ba40bc..43b5a67e1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -62,10 +62,10 @@ jobs: --health-cmd="mariadb-admin ping" --health-interval=10s --health-timeout=5s --health-retries=5 mssql2019: - image: mcmoe/mssqldocker:v2019.CU4.0 + image: ghcr.io/uptrace/mssql:latest env: ACCEPT_EULA: Y - SA_PASSWORD: passWORD1 + MYSQL_SA_PASSWORD: passWORD1 MSSQL_DB: test MSSQL_USER: sa MSSQL_PASSWORD: passWORD1 diff --git a/.github/workflows/mssql-container.yml b/.github/workflows/mssql-container.yml new file mode 100644 index 000000000..3dc172c2e --- /dev/null +++ b/.github/workflows/mssql-container.yml @@ -0,0 +1,29 @@ +name: Build Image for MSSQL + +on: + workflow_dispatch: + +jobs: + build-and-push: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Log in to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build Docker image + working-directory: internal/dbtest/mssql-docker + run: | + docker build -t ghcr.io/${{ github.repository_owner }}/mssql:latest . + + # 推送镜像到 GHCR + - name: Push Docker image + run: | + docker push ghcr.io/${{ github.repository_owner }}/mssql:latest diff --git a/internal/dbtest/mssql-docker/Dockerfile b/internal/dbtest/mssql-docker/Dockerfile index d3aceecaa..9073a2545 100644 --- a/internal/dbtest/mssql-docker/Dockerfile +++ b/internal/dbtest/mssql-docker/Dockerfile @@ -1,12 +1,14 @@ FROM mcr.microsoft.com/mssql/server:2019-CU29-ubuntu-20.04 -RUN openssl req -x509 -nodes -newkey rsa:2048 -subj '/CN=mssql' -addext "subjectAltName = DNS:mssql" -keyout /etc/ssl/private/mssql.key -out /etc/ssl/certs/mssql.pem -days 7 --set_serial 01 -RUN chmod 400 /etc/ssl/private/mssql.key -RUN chmod 400 /etc/ssl/certs/mssql.pem RUN mkdir -p /var/opt/mssql +RUN openssl req -x509 -nodes -newkey rsa:2048 \ + -subj '/CN=mssql' -addext "subjectAltName = DNS:mssql" \ + -keyout /var/opt/mssql/mssql.key -out /var/opt/mssql/mssql.pem \ + -days 7 -set_serial 01 +RUN chmod 400 /var/opt/mssql/mssql.key && \ + chmod 400 /var/opt/mssql/mssql.pem COPY mssql.conf /var/opt/mssql/mssql.conf - # Create a config directory RUN mkdir -p /usr/config WORKDIR /usr/config @@ -15,3 +17,4 @@ WORKDIR /usr/config COPY . /usr/config ENTRYPOINT ["./entrypoint.sh"] + diff --git a/internal/dbtest/mssql-docker/mssql.conf b/internal/dbtest/mssql-docker/mssql.conf index 4f3641d60..830ea13f9 100644 --- a/internal/dbtest/mssql-docker/mssql.conf +++ b/internal/dbtest/mssql-docker/mssql.conf @@ -1,5 +1,5 @@ [network] -tlscert = /etc/ssl/certs/mssql.pem -tlskey = /etc/ssl/private/mssql.key +tlscert = /var/opt/mssql/mssql.pem +tlskey = /var/opt/mssql/mssql.key tlsprotocols = 1.2 forceencryption = 1