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

Use a docker registry for cache #283

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open

Conversation

joelwurtz
Copy link
Member

@joelwurtz joelwurtz commented Feb 27, 2024

Fix #252

WHat it does :

  • remove USER_ID features from dockerfile: Without this change the USER_ID make the image dependant on the system that run this command wich creates differents images and make them not shareable
  • run frontend / builder / worker as a specific user id : we don't use a named user anymore to avoid headcache when mapping it to a different user id
  • local and shared home directory : This allow to debug home directory and files created in it (like composer cache), allow end users to put special scripts in it (like a custom bashrc), and also allow to cache this folder or specific subfolders of this directory within the CI (like the composer / yarn cache)
  • command to generate a bake file which allow to push images to the registry
  • sudo : it use gosu to fake it since we don't have a named user, it also disable by default as it may be a security risk if image is used in production

@joelwurtz joelwurtz marked this pull request as ready for review April 25, 2024 14:32
@joelwurtz joelwurtz force-pushed the feat/registry-docker branch 5 times, most recently from 53e57e2 to 91c5947 Compare April 29, 2024 12:35
@lyrixx
Copy link
Member

lyrixx commented May 3, 2024

Is there a simple way to get sudo back? I need it quiet often

.castor/docker.php Show resolved Hide resolved
.castor/docker.php Outdated Show resolved Hide resolved
.castor/docker.php Outdated Show resolved Hide resolved
.castor/docker.php Outdated Show resolved Hide resolved
.github/workflows/ci.yml Show resolved Hide resolved
infrastructure/docker/services/php/Dockerfile Show resolved Hide resolved
infrastructure/docker/services/php/Dockerfile Show resolved Hide resolved
infrastructure/docker/services/php/Dockerfile Show resolved Hide resolved
@joelwurtz
Copy link
Member Author

joelwurtz commented May 3, 2024

Is there a simple way to get sudo back? I need it quiet often

done

Copy link
Member

@lyrixx lyrixx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏼

.castor/docker.php Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
@joelwurtz joelwurtz force-pushed the feat/registry-docker branch 2 times, most recently from b408ca5 to 19efd5e Compare May 7, 2024 07:02
@lyrixx
Copy link
Member

lyrixx commented Jun 9, 2024

Hello,

Thanks for this PR!

I tested it on jolicode/qotd#62 and

  • I miss some doc about how to use cache (not how to push, but how to get it). For example, on GHA, you have to re-install docker to make it work
  • By default, on my computer, I had to change the driver to add support for registry cache storage. It could be nice to explain how to do that
    cat /etc/docker/daemon.json 
    {
      "features": {
        "containerd-snapshotter": true
      }
    }
    
  • However, cache is still missing on GHA
  • I also tried to create a VM, and the cache is missing there too
    Vagrant.configure("2") do |config|
      config.vm.box = "debian/bookworm64"
      config.vm.synced_folder "/home/gregoire/dev/github.com/jolicode/qotd2", "/qotd"
      config.vm.provider "virtualbox" do |vb|
        vb.memory = "4096"
      end
      config.vm.provision "shell", inline: <<-SHELL
        apt-get update
        sudo apt-get update
        sudo apt-get install -y ca-certificates curl
        sudo install -m 0755 -d /etc/apt/keyrings
        sudo curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc
        sudo chmod a+r /etc/apt/keyrings/docker.asc
    
        # Add the repository to Apt sources:
        echo \
          "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian \
          $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
          sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
        sudo apt-get update
    
        sudo apt-get -y install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
    
        sudo usermod -aG docker vagrant
    
        sudo wget https://github.com/jolicode/castor/releases/download/v0.17.1/castor.linux-amd64 -O /usr/local/bin/castor
        sudo chmod +x /usr/local/bin/castor
    
      SHELL
    end
    

@joelwurtz
Copy link
Member Author

joelwurtz commented Jun 9, 2024

Who push the cache ?

It is highly recommendend that cache is push by the CI, version of docker / config from where the cache is pushed need to be controled as special configuration or version may make him unshareable.

For the CI also i see this

image

Did you make sur that GHA has correct permissions to read this package ?

EDIT : In your case it miss the docker login step

@joelwurtz joelwurtz force-pushed the feat/registry-docker branch 2 times, most recently from 9755e6f to 323250c Compare June 10, 2024 08:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Provide a default Docker registry or layer cache by default
4 participants