ci: create compose file for each db

This commit is contained in:
Denis Gukov 2022-11-19 17:46:32 +05:00
parent 0d3ccfabe1
commit f8c16c2244
9 changed files with 86 additions and 40 deletions

View File

@ -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]

View File

@ -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:

View File

@ -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

View File

@ -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

View File

@ -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}"]

View File

@ -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"]

View File

@ -14,7 +14,7 @@ cat > /semaphore/.dredd/config.json <<EOF
EOF
echo "---> Waiting for semaphore"
while ! nc -z ${SEMAPHORE_SERVICE} ${SEMAPHORE_PORT}; do
while ! nc -z semaphore_ci 3000; do
sleep 1
done

View File

@ -6,17 +6,18 @@ echo "---> Add Config"
cat > /semaphore/.dredd/config.json <<EOF
{
"mysql": {
"host": "${MYSQL_SERVICE}:${MYSQL_PORT}",
"host": "mysql:3306",
"user": "semaphore",
"pass": "semaphore",
"name": "semaphore"
},
"dialect": "mysql",
"access_key_encryption": "${SEMAPHORE_ACCESS_KEY_ENCRYPTION}"
}
EOF
echo "---> Waiting for semaphore"
while ! nc -z ${SEMAPHORE_SERVICE} ${SEMAPHORE_PORT}; do
while ! nc -z semaphore_ci 3000; do
sleep 1
done

View File

@ -0,0 +1,27 @@
#!/usr/bin/env bash
set -e
echo "---> Add Config"
cat > /semaphore/.dredd/config.json <<EOF
{
"postgres": {
"host": "postgres:5342",
"user": "semaphore",
"pass": "semaphore",
"name": "semaphore"
},
"dialect": "postgres",
"access_key_encryption": "${SEMAPHORE_ACCESS_KEY_ENCRYPTION}"
}
EOF
echo "---> 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 $@