diff --git a/.github/workflows/test_and_build.yml b/.github/workflows/test_and_build.yml index 5c0847f01..30f47749b 100644 --- a/.github/workflows/test_and_build.yml +++ b/.github/workflows/test_and_build.yml @@ -36,17 +36,32 @@ jobs: touch .env.local fi - - name: Build App Image + - name: Build App and Webserver Images run: | cd docker - docker compose build --no-cache webserver app + docker compose build --no-cache webserver app fakes3 - - name: Push App Images + - name: Push Dev App and Webserver Images + if: ${{ startsWith(github.ref, 'refs/tags/v') && (contains(github.ref, '-alpha') || contains(github.ref, '-rc')) }} run: | - docker tag ucfopen/materia:app-dev ghcr.io/${{ github.repository_owner }}/materia:app-${{ github.sha }} - docker tag ucfopen/materia:app-dev ghcr.io/${{ github.repository_owner }}/materia:app-${{ steps.tag_name.outputs.GIT_TAG }} - docker tag ucfopen/materia:webserver-dev ghcr.io/${{ github.repository_owner }}/materia:webserver-${{ github.sha }} - docker tag ucfopen/materia:webserver-dev ghcr.io/${{ github.repository_owner }}/materia:webserver-${{ steps.tag_name.outputs.GIT_TAG }} + docker push ghcr.io/${{ github.repository_owner }}/materia:app-dev + docker push ghcr.io/${{ github.repository_owner }}/materia:webserver-dev + docker push ghcr.io/${{ github.repository_owner }}/materia:fake-s3-dev + + - name: Push Stable App and Webserver Images + if: ${{ startsWith(github.ref, 'refs/tags/v') && !contains(github.ref, '-alpha') && !contains(github.ref, '-rc') }} + run: | + docker tag ghcr.io/${{ github.repository_owner }}/materia:app-dev ghcr.io/${{ github.repository_owner }}/materia:app-stable + docker tag ghcr.io/${{ github.repository_owner }}/materia:webserver-dev ghcr.io/${{ github.repository_owner }}/materia:webserver-stable + docker push ghcr.io/${{ github.repository_owner }}/materia:app-stable + docker push ghcr.io/${{ github.repository_owner }}/materia:webserver-stable + + - name: Push Versioned App and Webserver Images + run: | + docker tag ghcr.io/${{ github.repository_owner }}/materia:app-dev ghcr.io/${{ github.repository_owner }}/materia:app-${{ github.sha }} + docker tag ghcr.io/${{ github.repository_owner }}/materia:app-dev ghcr.io/${{ github.repository_owner }}/materia:app-${{ steps.tag_name.outputs.GIT_TAG }} + docker tag ghcr.io/${{ github.repository_owner }}/materia:webserver-dev ghcr.io/${{ github.repository_owner }}/materia:webserver-${{ github.sha }} + docker tag ghcr.io/${{ github.repository_owner }}/materia:webserver-dev ghcr.io/${{ github.repository_owner }}/materia:webserver-${{ steps.tag_name.outputs.GIT_TAG }} docker push ghcr.io/${{ github.repository_owner }}/materia:app-${{ github.sha }} docker push ghcr.io/${{ github.repository_owner }}/materia:app-${{ steps.tag_name.outputs.GIT_TAG }} docker push ghcr.io/${{ github.repository_owner }}/materia:webserver-${{ github.sha }} @@ -70,7 +85,7 @@ jobs: overwrite: true - name: Upload to Pre-Release - if: ${{ startsWith(github.ref, 'refs/tags/v') && contains(github.ref, '-alpha') && contains(github.ref, '-rc') }} + if: ${{ startsWith(github.ref, 'refs/tags/v') && contains(github.ref, '-alpha') || contains(github.ref, '-rc') }} uses: svenstaro/upload-release-action@v2 with: repo_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index e3f67c267..59818fd82 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -2,7 +2,7 @@ version: '3.5' services: webserver: - image: ucfopen/materia:webserver-dev + image: ghcr.io/ucfopen/materia:webserver-dev build: context: ../ dockerfile: materia-webserver.Dockerfile @@ -16,7 +16,7 @@ services: - app app: - image: ucfopen/materia:app-dev + image: ghcr.io/ucfopen/materia:app-dev build: context: ../ dockerfile: materia-app.Dockerfile @@ -52,7 +52,7 @@ services: - backend mysql: - image: mysql:5.7.34 + image: mysql:8.0.32 platform: linux/amd64 ports: - "3306:3306" # allow mysql access from the host - use /etc/hosts to set mysql to your docker-machine ip @@ -67,7 +67,7 @@ services: - backend fakes3: - image: ucfopen/materia:fake-s3-dev + image: ghcr.io/ucfopen/materia:fake-s3-dev build: context: ../ dockerfile: materia-fake-s3.Dockerfile diff --git a/docker/run_first.sh b/docker/run_first.sh index 9e2ec6a2a..3235e1df8 100755 --- a/docker/run_first.sh +++ b/docker/run_first.sh @@ -23,11 +23,27 @@ rm -rf ./config/nginx/cert.pem # generate a self-signed ssl cert openssl req -subj '/CN=localhost' -x509 -newkey rsa:4096 -nodes -keyout ./config/nginx/key.pem -out ./config/nginx/cert.pem -days 365 -# quietly pull any docker images we can -docker compose pull --ignore-pull-failures +echo "To setup Materia locally, you can choose to pull pre-packaged images or build from source" +echo "1. Pull app and webserver images (recommended if you just want to run Materia locally with no dev)" +echo "2. Build images from source (recommended if you're actively developing Materia)" +read -p "Enter an option (1 or 2): " choice -# install php composer deps -docker compose run --rm --no-deps app composer install --ignore-platform-reqs +if [ "$choice" == "1" ]; then + echo "Pulling containers..." + # quietly pull any docker images we can + docker compose pull + + +elif [ "$choice" == "2" ]; then + echo "Building containers. This will take a few minutes..." + docker compose build app webserver fakes3 + + # install php composer deps + docker compose run --rm --no-deps app composer install --ignore-platform-reqs +else + echo "Invalid choice. Try again." + exit 1 +fi # run migrations and seed any db data needed for a new install docker compose run --rm app /wait-for-it.sh mysql:3306 --timeout=120 --strict -- composer oil-install-quiet @@ -38,12 +54,10 @@ docker compose run --rm app bash -c 'php oil r widget:install_from_config' # Install any widgets in the tmp dir source run_widgets_install.sh '*.wigt' -# build all the js/css assets -source run_build_assets.sh - # create a dev user based on your current shell user (password will be 'kogneato') MATERIA_DEV_PASS=whatever can be used to set a custom pw source run_create_me.sh echo -e "Materia will be hosted on \033[32m$DOCKER_IP\033[0m" -echo -e "\033[1mRun an oil comand:\033[0m ./run.sh php oil r widget:show_engines" -echo -e "\033[1mRun the web app:\033[0m docker compose up" +echo -e '\033[1mRun an oil comand:\033[0m ./run.sh php oil r widget:show_engines' +echo -e '\033[1mRun the web app:\033[0m docker compose up' +echo -e 'Doing local dev? Be sure to \033[1myarn install\033[0m and \033[1myarn dev\033[0m to run the local webpack dev server'