diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index d95397bf..a5159b95 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -85,8 +85,7 @@ jobs: - uses: actions/checkout@v3 - run: context=ci prefix=.bolt task dc:up - - - run: context=ci task dc:up + - run: context=ci prefix=.mysql task dc:up deploy-dev: runs-on: [ubuntu-latest] diff --git a/deployment/docker/ci/docker-compose.bolt.yml b/deployment/docker/ci/docker-compose.bolt.yml index 3902be9a..5a91694d 100644 --- a/deployment/docker/ci/docker-compose.bolt.yml +++ b/deployment/docker/ci/docker-compose.bolt.yml @@ -27,9 +27,10 @@ services: command: [ "--config", ".dredd/dredd.yml" ] environment: SEMAPHORE_ACCESS_KEY_ENCRYPTION: "IlRqgrrO5Gp27MlWakDX1xVrPv4jhoUx+ARY+qGyDxQ=" + SEMAPHORE_DB_DIALECT: bolt build: context: ./../../../ - dockerfile: ./deployment/docker/ci/dredd.bolt.Dockerfile + dockerfile: ./deployment/docker/ci/dredd.Dockerfile depends_on: - semaphore_ci volumes: diff --git a/deployment/docker/ci/docker-compose.yml b/deployment/docker/ci/docker-compose.mysql.yml similarity index 97% rename from deployment/docker/ci/docker-compose.yml rename to deployment/docker/ci/docker-compose.mysql.yml index 0347dbad..e73e379d 100644 --- a/deployment/docker/ci/docker-compose.yml +++ b/deployment/docker/ci/docker-compose.mysql.yml @@ -39,6 +39,7 @@ services: command: ["--config", ".dredd/dredd.yml"] environment: SEMAPHORE_ACCESS_KEY_ENCRYPTION: "IlRqgrrO5Gp27MlWakDX1xVrPv4jhoUx+ARY+qGyDxQ=" + SEMAPHORE_DB_DIALECT: mysql build: context: ./../../../ dockerfile: ./deployment/docker/ci/dredd.Dockerfile diff --git a/deployment/docker/ci/docker-compose.postgres.yml b/deployment/docker/ci/docker-compose.postgres.yml new file mode 100644 index 00000000..562de384 --- /dev/null +++ b/deployment/docker/ci/docker-compose.postgres.yml @@ -0,0 +1,49 @@ +version: '2' + +services: + postgres: + image: mysql:5.6 + environment: + MYSQL_RANDOM_ROOT_PASSWORD: 'yes' + MYSQL_DATABASE: semaphore + MYSQL_USER: semaphore + MYSQL_PASSWORD: semaphore + ports: + - "3306:3306" + + semaphore_ci: + image: semaphoreui/semaphore:ci-compose + build: + context: ./../../../ + dockerfile: ./deployment/docker/ci/Dockerfile + environment: + SEMAPHORE_DB_DIALECT: mysql + SEMAPHORE_DB_USER: semaphore + SEMAPHORE_DB_PASS: semaphore + SEMAPHORE_DB_HOST: mysql + SEMAPHORE_DB_PORT: 3306 + SEMAPHORE_DB: semaphore + SEMAPHORE_ADMIN_PASSWORD: password + SEMAPHORE_ADMIN_NAME: "Developer" + SEMAPHORE_ADMIN_EMAIL: admin@localhost + SEMAPHORE_ADMIN: admin + SEMAPHORE_WEB_ROOT: http://0.0.0.0:3000 + SEMAPHORE_ACCESS_KEY_ENCRYPTION: "IlRqgrrO5Gp27MlWakDX1xVrPv4jhoUx+ARY+qGyDxQ=" + ports: + - "3000:3000" + depends_on: + - postgres + + dredd: + image: ansiblesemaphore/dredd:ci + command: ["--config", ".dredd/dredd.yml"] + environment: + SEMAPHORE_ACCESS_KEY_ENCRYPTION: "IlRqgrrO5Gp27MlWakDX1xVrPv4jhoUx+ARY+qGyDxQ=" + SEMAPHORE_DB_DIALECT: postgres + build: + context: ./../../../ + dockerfile: ./deployment/docker/ci/dredd.Dockerfile + depends_on: + - semaphore_ci + - postgres + diff --git a/deployment/docker/ci/dredd.Dockerfile b/deployment/docker/ci/dredd.Dockerfile index 4242bb3d..f1b76371 100644 --- a/deployment/docker/ci/dredd.Dockerfile +++ b/deployment/docker/ci/dredd.Dockerfile @@ -19,11 +19,6 @@ COPY --from=golang /semaphore /semaphore WORKDIR /semaphore -COPY deployment/docker/ci/dredd/entrypoint /usr/local/bin +COPY deployment/docker/ci/dredd/entrypoint.${SEMAPHORE_DIALECT} /usr/local/bin -ENV SEMAPHORE_SERVICE=semaphore_ci \ - SEMAPHORE_PORT=3000 \ - MYSQL_SERVICE=mysql \ - MYSQL_PORT=3306 - -ENTRYPOINT ["/usr/local/bin/entrypoint"] +ENTRYPOINT ["/usr/local/bin/entrypoint.${SEMAPHORE_DIALECT}"] diff --git a/deployment/docker/ci/dredd.bolt.Dockerfile b/deployment/docker/ci/dredd.bolt.Dockerfile deleted file mode 100644 index 83927fe5..00000000 --- a/deployment/docker/ci/dredd.bolt.Dockerfile +++ /dev/null @@ -1,27 +0,0 @@ -FROM golang:1.18.3-alpine3.16 as golang - -RUN apk add --no-cache curl git - -# We need the source and task to compile the hooks -COPY . /semaphore/ - -RUN (cd /usr && curl -sL https://taskfile.dev/install.sh | sh) -WORKDIR /semaphore -RUN task deps:tools && task deps:be && task compile:be && task compile:api:hooks - -FROM apiaryio/dredd:13.0.0 as dredd - -RUN apk add --no-cache bash go git - -RUN go get github.com/snikch/goodman/cmd/goodman - -COPY --from=golang /semaphore /semaphore - -WORKDIR /semaphore - -COPY deployment/docker/ci/dredd/entrypoint.bolt /usr/local/bin - -ENV SEMAPHORE_SERVICE=semaphore_ci \ - SEMAPHORE_PORT=3000 - -ENTRYPOINT ["/usr/local/bin/entrypoint.bolt"] diff --git a/deployment/docker/ci/dredd/entrypoint.bolt b/deployment/docker/ci/dredd/entrypoint.bolt index 560b2703..52d750e3 100644 --- a/deployment/docker/ci/dredd/entrypoint.bolt +++ b/deployment/docker/ci/dredd/entrypoint.bolt @@ -14,7 +14,7 @@ cat > /semaphore/.dredd/config.json < Waiting for semaphore" -while ! nc -z ${SEMAPHORE_SERVICE} ${SEMAPHORE_PORT}; do +while ! nc -z semaphore_ci 3000; do sleep 1 done diff --git a/deployment/docker/ci/dredd/entrypoint b/deployment/docker/ci/dredd/entrypoint.mysql old mode 100755 new mode 100644 similarity index 79% rename from deployment/docker/ci/dredd/entrypoint rename to deployment/docker/ci/dredd/entrypoint.mysql index d94611dc..34a3ba2b --- a/deployment/docker/ci/dredd/entrypoint +++ b/deployment/docker/ci/dredd/entrypoint.mysql @@ -6,17 +6,18 @@ echo "---> Add Config" cat > /semaphore/.dredd/config.json < Waiting for semaphore" -while ! nc -z ${SEMAPHORE_SERVICE} ${SEMAPHORE_PORT}; do +while ! nc -z semaphore_ci 3000; do sleep 1 done diff --git a/deployment/docker/ci/dredd/entrypoint.postgres b/deployment/docker/ci/dredd/entrypoint.postgres new file mode 100644 index 00000000..6a05b748 --- /dev/null +++ b/deployment/docker/ci/dredd/entrypoint.postgres @@ -0,0 +1,27 @@ +#!/usr/bin/env bash + +set -e + +echo "---> Add Config" +cat > /semaphore/.dredd/config.json < Waiting for semaphore" +while ! nc -z semaphore_ci 3000; do + sleep 1 +done + +echo "---> Run Dredd" +# We do this because otherwise it can fail out +sleep 5 +dredd $@