From fd1fe5c50475029f18acf75a2d24708e26353fd6 Mon Sep 17 00:00:00 2001 From: Rodrigo Ipince Date: Thu, 12 Sep 2024 14:43:12 +0300 Subject: [PATCH 01/15] [wip] Test building flask template --- .github/workflows/publish-repos.yml | 25 +++++++++++++------------ actions/publish-image/action.yml | 2 ++ 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/.github/workflows/publish-repos.yml b/.github/workflows/publish-repos.yml index e74abd1..f2b36aa 100644 --- a/.github/workflows/publish-repos.yml +++ b/.github/workflows/publish-repos.yml @@ -11,6 +11,7 @@ on: push: branches: - main # When we merge to main + - rodrigo/* tags: - "**" # If we added a tag (used for releases) @@ -26,8 +27,8 @@ jobs: publish-template-images: strategy: matrix: - project_id: [dev-j3tpk, nonprod-j3tpk, prod-j3tpk] - template: [deno-fresh, elixir-phoenix, php-laravel, python-flask] + project_id: [dev-j3tpk] #, nonprod-j3tpk, prod-j3tpk] + template: [python-flask] #template: [deno-fresh, elixir-phoenix, php-laravel, python-flask] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -40,16 +41,16 @@ jobs: with: gcp_project: ${{ matrix.project_id }} template: templates/${{ matrix.template }} - - uses: webfactory/ssh-agent@v0.9.0 - if: ${{ matrix.project_id == 'prod-j3tpk' && github.ref == 'refs/heads/main' }} - with: - ssh-private-key: ${{ secrets.CODEBOT_SSH_KEY }} - - uses: ./actions/publish-code - if: ${{ matrix.project_id == 'prod-j3tpk' && github.ref == 'refs/heads/main' }} - with: - origin: ${{ github.repository }} - targets: > - templates/${{ matrix.template}}:jetify-examples/${{ matrix.template }} +# - uses: webfactory/ssh-agent@v0.9.0 +# if: ${{ matrix.project_id == 'prod-j3tpk' && github.ref == 'refs/heads/main' }} +# with: +# ssh-private-key: ${{ secrets.CODEBOT_SSH_KEY }} +# - uses: ./actions/publish-code +# if: ${{ matrix.project_id == 'prod-j3tpk' && github.ref == 'refs/heads/main' }} +# with: +# origin: ${{ github.repository }} +# targets: > +# templates/${{ matrix.template}}:jetify-examples/${{ matrix.template }} publish-repos: # Only publish if tests pass. Right now all tests for all repos need to pass, but as the monorepo diff --git a/actions/publish-image/action.yml b/actions/publish-image/action.yml index a4a9f2b..8802351 100644 --- a/actions/publish-image/action.yml +++ b/actions/publish-image/action.yml @@ -59,6 +59,8 @@ runs: if [ ! -f Dockerfile ]; then devbox generate dockerfile --for prod fi + cat Dockerfile + devbox version docker build . \ --label "repository=${{ github.repository }}" \ --label "revision=${{ github.sha }}" \ From 79d83ea236f4991299d3f30f7e058ffca26a8b8a Mon Sep 17 00:00:00 2001 From: Rodrigo Ipince Date: Thu, 12 Sep 2024 15:02:02 +0300 Subject: [PATCH 02/15] print out more stuff --- templates/python-flask/devbox.json | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/templates/python-flask/devbox.json b/templates/python-flask/devbox.json index ddeb420..2a82bd0 100644 --- a/templates/python-flask/devbox.json +++ b/templates/python-flask/devbox.json @@ -3,10 +3,14 @@ "packages": ["python@3.11"], "shell": { "init_hook": [ - ". $VENV_DIR/bin/activate" + "echo 'in init hook'", + "which pip", + ". $VENV_DIR/bin/activate", + "which pip", + "echo 'end of init hook'" ], "scripts": { - "install": "pip install -r requirements.txt", + "install": ["echo 'START install'", "which pip", ". $VENV_DIR/bin/activate", "echo 'AFTER activate'", "which pip", "pip install -r requirements.txt"], "start": "gunicorn -w 2 -b 0.0.0.0:8080 main:app" } } From 128b3607132d8fd812b02a764c62c4a8f22f3954 Mon Sep 17 00:00:00 2001 From: Rodrigo Ipince Date: Thu, 12 Sep 2024 15:09:49 +0300 Subject: [PATCH 03/15] try again --- templates/python-flask/devbox.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/templates/python-flask/devbox.json b/templates/python-flask/devbox.json index 2a82bd0..86e6648 100644 --- a/templates/python-flask/devbox.json +++ b/templates/python-flask/devbox.json @@ -4,7 +4,8 @@ "shell": { "init_hook": [ "echo 'in init hook'", - "which pip", + "echo $VENV_DIR", + "echo 'after echoing venv_dir'", ". $VENV_DIR/bin/activate", "which pip", "echo 'end of init hook'" From 7f544f17248fed857992b0f448148bd8fb828f25 Mon Sep 17 00:00:00 2001 From: Rodrigo Ipince Date: Thu, 12 Sep 2024 15:49:52 +0300 Subject: [PATCH 04/15] Try source --- templates/python-flask/devbox.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/python-flask/devbox.json b/templates/python-flask/devbox.json index 86e6648..d105fa3 100644 --- a/templates/python-flask/devbox.json +++ b/templates/python-flask/devbox.json @@ -6,7 +6,7 @@ "echo 'in init hook'", "echo $VENV_DIR", "echo 'after echoing venv_dir'", - ". $VENV_DIR/bin/activate", + "source $VENV_DIR/bin/activate", "which pip", "echo 'end of init hook'" ], From 27f36c6f850aaaf7c8de830d11b590c75215a6c5 Mon Sep 17 00:00:00 2001 From: Rodrigo Ipince Date: Thu, 12 Sep 2024 15:54:37 +0300 Subject: [PATCH 05/15] exec it --- actions/publish-image/action.yml | 1 + templates/python-flask/devbox.json | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/actions/publish-image/action.yml b/actions/publish-image/action.yml index 8802351..4c1f014 100644 --- a/actions/publish-image/action.yml +++ b/actions/publish-image/action.yml @@ -61,6 +61,7 @@ runs: fi cat Dockerfile devbox version + pwd docker build . \ --label "repository=${{ github.repository }}" \ --label "revision=${{ github.sha }}" \ diff --git a/templates/python-flask/devbox.json b/templates/python-flask/devbox.json index d105fa3..131ef39 100644 --- a/templates/python-flask/devbox.json +++ b/templates/python-flask/devbox.json @@ -6,7 +6,9 @@ "echo 'in init hook'", "echo $VENV_DIR", "echo 'after echoing venv_dir'", - "source $VENV_DIR/bin/activate", + "echo $SHELL", + "echo $0", + "./$VENV_DIR/bin/activate", "which pip", "echo 'end of init hook'" ], From 9c8df4950f4eb2e2a140355cc73998b055018e46 Mon Sep 17 00:00:00 2001 From: Rodrigo Ipince Date: Thu, 12 Sep 2024 16:04:40 +0300 Subject: [PATCH 06/15] one more time --- templates/python-flask/devbox.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/python-flask/devbox.json b/templates/python-flask/devbox.json index 131ef39..3951ce8 100644 --- a/templates/python-flask/devbox.json +++ b/templates/python-flask/devbox.json @@ -8,7 +8,7 @@ "echo 'after echoing venv_dir'", "echo $SHELL", "echo $0", - "./$VENV_DIR/bin/activate", + "$VENV_DIR/bin/activate", "which pip", "echo 'end of init hook'" ], From 3f24c983ab665f060a0be040ec8a816d763f5ab0 Mon Sep 17 00:00:00 2001 From: Rodrigo Ipince Date: Thu, 12 Sep 2024 16:09:10 +0300 Subject: [PATCH 07/15] ugh revert --- templates/python-flask/devbox.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/python-flask/devbox.json b/templates/python-flask/devbox.json index 3951ce8..e9935b1 100644 --- a/templates/python-flask/devbox.json +++ b/templates/python-flask/devbox.json @@ -8,7 +8,7 @@ "echo 'after echoing venv_dir'", "echo $SHELL", "echo $0", - "$VENV_DIR/bin/activate", + ". $VENV_DIR/bin/activate", "which pip", "echo 'end of init hook'" ], From d1983acb9036a4d11401a5126555b7d19d9100ff Mon Sep 17 00:00:00 2001 From: Rodrigo Ipince Date: Fri, 13 Sep 2024 14:53:38 +0300 Subject: [PATCH 08/15] try diff shell in dockerfile --- templates/python-flask/Dockerfile | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 templates/python-flask/Dockerfile diff --git a/templates/python-flask/Dockerfile b/templates/python-flask/Dockerfile new file mode 100644 index 0000000..de94a7e --- /dev/null +++ b/templates/python-flask/Dockerfile @@ -0,0 +1,17 @@ +FROM jetpackio/devbox:latest + +WORKDIR /code +USER root:root +RUN mkdir -p /code && chown ${DEVBOX_USER}:${DEVBOX_USER} /code +USER ${DEVBOX_USER}:${DEVBOX_USER} + +COPY --chown=${DEVBOX_USER}:${DEVBOX_USER} . . + +RUN devbox install + +SHELL ["/bin/bash", "-c"] +RUN devbox run install + +RUN echo 'No build script found, skipping' + +CMD ["devbox", "run", "start"] From 1bc03e59c12fa0a025912f1b42582ddda1548b10 Mon Sep 17 00:00:00 2001 From: Rodrigo Ipince Date: Fri, 13 Sep 2024 15:00:48 +0300 Subject: [PATCH 09/15] more echo --- templates/python-flask/devbox.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/templates/python-flask/devbox.json b/templates/python-flask/devbox.json index e9935b1..d9ff6a5 100644 --- a/templates/python-flask/devbox.json +++ b/templates/python-flask/devbox.json @@ -6,8 +6,9 @@ "echo 'in init hook'", "echo $VENV_DIR", "echo 'after echoing venv_dir'", - "echo $SHELL", - "echo $0", + "ls -la $VENV_DIR", + "ls -la $VENV_DIR/bin", + "echo 'before source'", ". $VENV_DIR/bin/activate", "which pip", "echo 'end of init hook'" From 72e15882e5b6522a3f3d21aa6878b84e72f10dd4 Mon Sep 17 00:00:00 2001 From: Rodrigo Ipince Date: Fri, 13 Sep 2024 15:16:09 +0300 Subject: [PATCH 10/15] add set -x --- templates/python-flask/devbox.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/templates/python-flask/devbox.json b/templates/python-flask/devbox.json index d9ff6a5..614d360 100644 --- a/templates/python-flask/devbox.json +++ b/templates/python-flask/devbox.json @@ -8,6 +8,8 @@ "echo 'after echoing venv_dir'", "ls -la $VENV_DIR", "ls -la $VENV_DIR/bin", + "sed -i '1i set -x' $VENV_DIR/bin/activate", + "cat $VENV_DIR/bin/activate", "echo 'before source'", ". $VENV_DIR/bin/activate", "which pip", From bf83adea5168f32975678b12236d1cd210f17299 Mon Sep 17 00:00:00 2001 From: Rodrigo Ipince Date: Fri, 13 Sep 2024 15:26:42 +0300 Subject: [PATCH 11/15] rm .devbox --- templates/python-flask/Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/templates/python-flask/Dockerfile b/templates/python-flask/Dockerfile index de94a7e..c9d05d3 100644 --- a/templates/python-flask/Dockerfile +++ b/templates/python-flask/Dockerfile @@ -6,6 +6,7 @@ RUN mkdir -p /code && chown ${DEVBOX_USER}:${DEVBOX_USER} /code USER ${DEVBOX_USER}:${DEVBOX_USER} COPY --chown=${DEVBOX_USER}:${DEVBOX_USER} . . +RUN rm -rf .devbox RUN devbox install From 03dfcf6588a66bea1f6e9ca0cd901f14dd797a00 Mon Sep 17 00:00:00 2001 From: Rodrigo Ipince Date: Fri, 13 Sep 2024 19:24:18 +0300 Subject: [PATCH 12/15] try the other templates --- .github/workflows/publish-repos.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish-repos.yml b/.github/workflows/publish-repos.yml index f2b36aa..8c37923 100644 --- a/.github/workflows/publish-repos.yml +++ b/.github/workflows/publish-repos.yml @@ -28,7 +28,7 @@ jobs: strategy: matrix: project_id: [dev-j3tpk] #, nonprod-j3tpk, prod-j3tpk] - template: [python-flask] #template: [deno-fresh, elixir-phoenix, php-laravel, python-flask] + template: [deno-fresh, elixir-phoenix, php-laravel] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 From d4f542588b45a585d2e35a8629730f7cacf924ac Mon Sep 17 00:00:00 2001 From: Rodrigo Ipince Date: Fri, 13 Sep 2024 20:09:08 +0300 Subject: [PATCH 13/15] fix flask only with dockerignore --- .github/workflows/publish-repos.yml | 2 +- actions/publish-image/action.yml | 3 --- templates/python-flask/Dockerfile | 18 ------------------ templates/python-flask/devbox.json | 14 ++------------ 4 files changed, 3 insertions(+), 34 deletions(-) delete mode 100644 templates/python-flask/Dockerfile diff --git a/.github/workflows/publish-repos.yml b/.github/workflows/publish-repos.yml index 8c37923..003075d 100644 --- a/.github/workflows/publish-repos.yml +++ b/.github/workflows/publish-repos.yml @@ -28,7 +28,7 @@ jobs: strategy: matrix: project_id: [dev-j3tpk] #, nonprod-j3tpk, prod-j3tpk] - template: [deno-fresh, elixir-phoenix, php-laravel] + template: [python-flask] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 diff --git a/actions/publish-image/action.yml b/actions/publish-image/action.yml index 4c1f014..a4a9f2b 100644 --- a/actions/publish-image/action.yml +++ b/actions/publish-image/action.yml @@ -59,9 +59,6 @@ runs: if [ ! -f Dockerfile ]; then devbox generate dockerfile --for prod fi - cat Dockerfile - devbox version - pwd docker build . \ --label "repository=${{ github.repository }}" \ --label "revision=${{ github.sha }}" \ diff --git a/templates/python-flask/Dockerfile b/templates/python-flask/Dockerfile deleted file mode 100644 index c9d05d3..0000000 --- a/templates/python-flask/Dockerfile +++ /dev/null @@ -1,18 +0,0 @@ -FROM jetpackio/devbox:latest - -WORKDIR /code -USER root:root -RUN mkdir -p /code && chown ${DEVBOX_USER}:${DEVBOX_USER} /code -USER ${DEVBOX_USER}:${DEVBOX_USER} - -COPY --chown=${DEVBOX_USER}:${DEVBOX_USER} . . -RUN rm -rf .devbox - -RUN devbox install - -SHELL ["/bin/bash", "-c"] -RUN devbox run install - -RUN echo 'No build script found, skipping' - -CMD ["devbox", "run", "start"] diff --git a/templates/python-flask/devbox.json b/templates/python-flask/devbox.json index 614d360..ddeb420 100644 --- a/templates/python-flask/devbox.json +++ b/templates/python-flask/devbox.json @@ -3,20 +3,10 @@ "packages": ["python@3.11"], "shell": { "init_hook": [ - "echo 'in init hook'", - "echo $VENV_DIR", - "echo 'after echoing venv_dir'", - "ls -la $VENV_DIR", - "ls -la $VENV_DIR/bin", - "sed -i '1i set -x' $VENV_DIR/bin/activate", - "cat $VENV_DIR/bin/activate", - "echo 'before source'", - ". $VENV_DIR/bin/activate", - "which pip", - "echo 'end of init hook'" + ". $VENV_DIR/bin/activate" ], "scripts": { - "install": ["echo 'START install'", "which pip", ". $VENV_DIR/bin/activate", "echo 'AFTER activate'", "which pip", "pip install -r requirements.txt"], + "install": "pip install -r requirements.txt", "start": "gunicorn -w 2 -b 0.0.0.0:8080 main:app" } } From 3e9c25136146abb5c13aaf7cec381fb7e4240300 Mon Sep 17 00:00:00 2001 From: Rodrigo Ipince Date: Fri, 13 Sep 2024 20:09:46 +0300 Subject: [PATCH 14/15] Actually add .dockerignore --- templates/python-flask/.dockerignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 templates/python-flask/.dockerignore diff --git a/templates/python-flask/.dockerignore b/templates/python-flask/.dockerignore new file mode 100644 index 0000000..872bcd4 --- /dev/null +++ b/templates/python-flask/.dockerignore @@ -0,0 +1 @@ +.devbox \ No newline at end of file From f9a284e6b170f048186c4ae14266954111502976 Mon Sep 17 00:00:00 2001 From: Rodrigo Ipince Date: Fri, 13 Sep 2024 20:15:31 +0300 Subject: [PATCH 15/15] clean up --- .github/workflows/publish-repos.yml | 25 ++++++++++++------------- templates/python-flask/.dockerignore | 2 +- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/.github/workflows/publish-repos.yml b/.github/workflows/publish-repos.yml index 003075d..e74abd1 100644 --- a/.github/workflows/publish-repos.yml +++ b/.github/workflows/publish-repos.yml @@ -11,7 +11,6 @@ on: push: branches: - main # When we merge to main - - rodrigo/* tags: - "**" # If we added a tag (used for releases) @@ -27,8 +26,8 @@ jobs: publish-template-images: strategy: matrix: - project_id: [dev-j3tpk] #, nonprod-j3tpk, prod-j3tpk] - template: [python-flask] + project_id: [dev-j3tpk, nonprod-j3tpk, prod-j3tpk] + template: [deno-fresh, elixir-phoenix, php-laravel, python-flask] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -41,16 +40,16 @@ jobs: with: gcp_project: ${{ matrix.project_id }} template: templates/${{ matrix.template }} -# - uses: webfactory/ssh-agent@v0.9.0 -# if: ${{ matrix.project_id == 'prod-j3tpk' && github.ref == 'refs/heads/main' }} -# with: -# ssh-private-key: ${{ secrets.CODEBOT_SSH_KEY }} -# - uses: ./actions/publish-code -# if: ${{ matrix.project_id == 'prod-j3tpk' && github.ref == 'refs/heads/main' }} -# with: -# origin: ${{ github.repository }} -# targets: > -# templates/${{ matrix.template}}:jetify-examples/${{ matrix.template }} + - uses: webfactory/ssh-agent@v0.9.0 + if: ${{ matrix.project_id == 'prod-j3tpk' && github.ref == 'refs/heads/main' }} + with: + ssh-private-key: ${{ secrets.CODEBOT_SSH_KEY }} + - uses: ./actions/publish-code + if: ${{ matrix.project_id == 'prod-j3tpk' && github.ref == 'refs/heads/main' }} + with: + origin: ${{ github.repository }} + targets: > + templates/${{ matrix.template}}:jetify-examples/${{ matrix.template }} publish-repos: # Only publish if tests pass. Right now all tests for all repos need to pass, but as the monorepo diff --git a/templates/python-flask/.dockerignore b/templates/python-flask/.dockerignore index 872bcd4..0ad3e13 100644 --- a/templates/python-flask/.dockerignore +++ b/templates/python-flask/.dockerignore @@ -1 +1 @@ -.devbox \ No newline at end of file +.devbox