Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alpine image and pipeline #103

Merged
merged 33 commits into from
Feb 21, 2024
Merged

Alpine image and pipeline #103

merged 33 commits into from
Feb 21, 2024

Conversation

mattbell87
Copy link
Member

@mattbell87 mattbell87 commented Feb 16, 2024

This PR contains multiple features:

  • New Alpine based boilerplate image with faster build times and smaller size
  • Another complete cmfive image with included core and compiled theme. Based upon the boilerplate image
  • GitHub Pipeline which automatically builds and tags the complete cmfive image and pushes it to GHCR
  • Boilerplate docker-compose file now uses the pre-built image for development (files are still mapped in the same way)
  • Extensive .dockerignore to remove unneeded files in image
  • Various improvements to permission handling, also nginx runs as cmfive user
  • Detailed container logs (php errors etc)

Checklist

  • Boilerplate docker-compose brings up a fully working development container. No errors, theme compiling changes on the fly.
  • Image can run in a container independent from the repo with no volumes/binds. No errors, theme visible.
  • Image can run in a pod on Kubernetes. No errors, theme visible.
  • Codespace-Dev-Box repo can use the new image correctly. No errors, theme visible.
  • Codespace-Dev-Box tests pass (not sure if we can test this before merge?) get this going later
  • Playwright tests work
  • XDebug works Skipping this and investigating again later

TODO:

  • Codespace-Dev-Box needs access to ghcr image
  • Before Merge - Change tag in docker compose to develop branch
  • Check live compiling on theme after permission changes
  • Codespace-Dev-Box logs in to GHCR @Dane-2pi

@mattbell87 mattbell87 changed the title Alpine Image and pipeline Alpine image and pipeline Feb 16, 2024
@chris-bateman chris-bateman added enhancement awaiting-review Awaiting on a code review labels Feb 19, 2024
@adam-buckley
Copy link
Contributor

@adam-buckley my only issue with this is the idea of referencing the dev/feature branch of core during a build.

@chris-bateman what dev branch are you referring to?

On cmfive core?

RUN git clone --depth 1 https://github.com/2pisoftware/cmfive-core
This would clone master, not develop.

Either way for prod releases the branches are set in our CDK

@chris-bateman
Copy link
Member

@adam-buckley my only issue with this is the idea of referencing the dev/feature branch of core during a build.

@chris-bateman what dev branch are you referring to?

On cmfive core?

RUN git clone --depth 1 https://github.com/2pisoftware/cmfive-core This would clone master, not develop.

Either way for prod releases the branches are set in our CDK

Yep aware it would clone master.
However since we are moving to docker files and potentially deploying said docker files to production. Setting the CDK may no longer be suitable. So that needs a rethink as well.

@adam-buckley
Copy link
Contributor

Ah, noted. Something to discuss on Thursday

@mattbell87
Copy link
Member Author

mattbell87 commented Feb 19, 2024

Here's a chart which hopefully helps explain the logic behind this:

https://lucid.app/lucidchart/0ab9565c-59aa-4a43-92ca-d8cddb0e0377/edit?viewport_loc=99%2C-532%2C4129%2C2122%2C0_0&invitationId=inv_3984acfe-5160-4aeb-811f-a80d33891147

So the main cmfive image in /.codepipeline/docker should contain something more ideal for production (so the main branch) baked in. But when we use the docker-compose file for development your local boilerplate and system/core are mapped in to the container (overriding the baked in stuff). So it will use the branch you have switched to locally (outside the container) in git.

@mattbell87
Copy link
Member Author

@chris-bateman I tried another dev-box rebuild, still hits this?:
image

@chris-bateman
Copy link
Member

@chris-bateman I tried another dev-box rebuild, still hits this?:
image

Did we auth boilerplate as well? I thought we only did core

@mattbell87
Copy link
Member Author

Did we auth boilerplate as well? I thought we only did core

That image includes boilerplate + core

@mattbell87
Copy link
Member Author

Hi @Dane-2pi, I've done some testing with this branch on codespace-dev-box and I've got it working.

Since the docker-compose file has a GHCR hosted image now it'll need to log in somewhere before doing the docker compose up. Here is some code you can use in the preBuildScript.sh:

# Log in to GHCR
echo "  logging into GHCR."  | tee -a $log_file
echo $GITHUB_TOKEN | docker login ghcr.io -u $GITHUB_USER --password-stdin

# docker compose up ...

You can implement this before this PR merges and it wont affect anything.

@Dane-2pi
Copy link
Contributor

I'll target this branch and see what happens.

Does that command ask for a password from stdin? That doesn't work for a prebuild script at all. It could come from an envvar, but even that's not ideal

@mattbell87
Copy link
Member Author

I'll target this branch and see what happens.

Does that command ask for a password from stdin? That doesn't work for a prebuild script at all. It could come from an envvar, but even that's not ideal

Stdin is left of the pipe (so echo'd in). It wont ask for input. I tested it on an existing codespace and it worked, but I haven't tried it on a fresh one.

@Dane-2pi
Copy link
Contributor

Dane-2pi commented Feb 19, 2024 via email

@mattbell87
Copy link
Member Author

Playwright tests work just as before. I tested both with npm run test and with the vscode extension & trace viewer.

@Dane-2pi
Copy link
Contributor

I can log in to GHCR, but the mysql container still isn't coming up in GH actions
Seems to be working fine in codespaces itself, so I'm happy with a merge.

@mattbell87
Copy link
Member Author

mattbell87 commented Feb 20, 2024

2 things left

  • @adam-buckley to close off review discussions
  • @Dane-2pi to give me the OK that ghcr login is on develop branch of the codespace

@mattbell87 mattbell87 merged commit 46062ca into develop Feb 21, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting-review Awaiting on a code review enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants