Skip to content

Commit

Permalink
Merge pull request #1617 from ucfopen/issue/1616-run-first-script-upd…
Browse files Browse the repository at this point in the history
…ates

Docker image management updates + run_first script improvements
  • Loading branch information
clpetersonucf authored Oct 29, 2024
2 parents 978f98b + dc4efda commit 684f5e4
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 21 deletions.
31 changes: 23 additions & 8 deletions .github/workflows/test_and_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand All @@ -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 }}
Expand Down
8 changes: 4 additions & 4 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
32 changes: 23 additions & 9 deletions docker/run_first.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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'

0 comments on commit 684f5e4

Please sign in to comment.