diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 6c51b3c..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,8 +0,0 @@ -version: 2.1 -orbs: - shellcheck: circleci/shellcheck@2.2.4 -workflows: - check-scripts: - jobs: - - shellcheck/check: - dir: ./scripts diff --git a/.github/workflows/docker-test.yml b/.github/workflows/docker-test.yml new file mode 100644 index 0000000..d295f8f --- /dev/null +++ b/.github/workflows/docker-test.yml @@ -0,0 +1,74 @@ +name: Docker Test + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + validate-compose-files: + name: Validate Docker Compose Files + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Setup environment file + run: | + cp env.example .env + + - name: Validate base docker-compose file + run: docker compose config + + - name: Validate docker-compose with NGINX + run: | + docker compose -f docker-compose.yml -f docker-compose.nginx.yml config + + - name: Validate docker-compose without NGINX + run: docker compose -f docker-compose.yml -f docker-compose.without-nginx.yml config + + test-docker-deployment: + name: Test Docker Deployment + runs-on: ubuntu-latest + needs: validate-compose-files + steps: + - uses: actions/checkout@v3 + + - name: Create required directories + run: | + mkdir -p ./volumes/app/mattermost/{config,data,logs,plugins,client/plugins,bleve-indexes} + sudo chown -R 2000:2000 ./volumes/app/mattermost + + - name: Setup environment file + run: | + cp env.example .env + sed -i 's/DOMAIN=mm.example.com/DOMAIN=localhost/g' .env + + - name: Start Mattermost without NGINX + run: | + # Configure docker-compose to use without-nginx setup + docker compose -f docker-compose.yml -f docker-compose.without-nginx.yml up -d + + - name: Verify containers are running + run: | + # Allow time for containers to start + sleep 30 + docker ps + docker compose ps + + - name: Check container logs + run: | + # Check logs for any issues + docker compose logs mattermost --tail 20 + docker compose logs postgres --tail 20 + + - name: Verify Mattermost API is accessible + run: | + # Check that API is responding + curl -f --retry 10 --retry-delay 5 --retry-connrefused http://localhost:8065/api/v4/system/ping || exit 1 + + - name: Stop containers + run: | + # Clean up containers + docker compose down + if: always() diff --git a/.github/workflows/shellcheck.yml b/.github/workflows/shellcheck.yml new file mode 100644 index 0000000..3b1da38 --- /dev/null +++ b/.github/workflows/shellcheck.yml @@ -0,0 +1,18 @@ +name: ShellCheck + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + shellcheck: + name: Shellcheck + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Run ShellCheck + uses: ludeeus/action-shellcheck@master + with: + scandir: "./scripts" diff --git a/scripts/upgrade-postgres.sh b/scripts/upgrade-postgres.sh index b1ba55b..2f5846c 100755 --- a/scripts/upgrade-postgres.sh +++ b/scripts/upgrade-postgres.sh @@ -103,7 +103,7 @@ fi if [[ $POSTGRES_UPGRADE_LINE == "" ]]; then echo "no exported POSTGRES_UPGRADE_LINE environment variable found" - echo "setting POSTGRES_UPGRADE_LINE to default $POSTGRES_OLD_VERSION-to-$POSTGRES_POSTGRES_NEW_VERSION" + echo "setting POSTGRES_UPGRADE_LINE to default $POSTGRES_OLD_VERSION-to-$POSTGRES_NEW_VERSION" echo "the POSTGRES_UPGRADE_LINE needs to match a folder found here - https://github.com/tianon/docker-postgres-upgrade" echo "it should read 'old-to-new'" POSTGRES_UPGRADE_LINE=$POSTGRES_OLD_VERSION-to-$POSTGRES_NEW_VERSION # i.e. '9.4-to-13' @@ -164,7 +164,7 @@ cp -ra "$PATH_TO_MATTERMOST_DOCKER"/volumes/db/ "$PATH_TO_MATTERMOST_DOCKER"/bac mkdir "$PATH_TO_MATTERMOST_DOCKER"/volumes/db/"$POSTGRES_OLD_VERSION" mv "$PATH_TO_MATTERMOST_DOCKER"/volumes/db/var/lib/postgresql/data/ "$PATH_TO_MATTERMOST_DOCKER"/volumes/db/"$POSTGRES_OLD_VERSION" rm -rf "$PATH_TO_MATTERMOST_DOCKER"/volumes/db/var -mkdir -p "$PATH_TO_MATTERMOST_DOCKER"/volumes/db/$POSTGRES_NEW_VERSION/data +mkdir -p "$PATH_TO_MATTERMOST_DOCKER"/volumes/db/"$POSTGRES_NEW_VERSION"/data sed -i "s/$POSTGRES_OLD_DOCKER_FROM/$POSTGRES_NEW_DOCKER_FROM/" "$PATH_TO_MATTERMOST_DOCKER"/db/Dockerfile @@ -185,7 +185,7 @@ docker run --rm \ tianon/postgres-upgrade:"$POSTGRES_UPGRADE_LINE" \ --link -cp -p "$PATH_TO_MATTERMOST_DOCKER"/volumes/db/"$POSTGRES_OLD_VERSION"/data/pg_hba.conf "$PATH_TO_MATTERMOST_DOCKER"/volumes/db/$POSTGRES_NEW_VERSION/data/ +cp -p "$PATH_TO_MATTERMOST_DOCKER"/volumes/db/"$POSTGRES_OLD_VERSION"/data/pg_hba.conf "$PATH_TO_MATTERMOST_DOCKER"/volumes/db/"$POSTGRES_NEW_VERSION"/data/ # rebuild the containers docker-compose build