<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: matiasbenary</title>
    <description>The latest articles on DEV Community by matiasbenary (@matiasbenary).</description>
    <link>https://dev.to/matiasbenary</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F367500%2F26632bfd-6e3c-441d-875e-2de1eaf3cfd3.png</url>
      <title>DEV Community: matiasbenary</title>
      <link>https://dev.to/matiasbenary</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/matiasbenary"/>
    <language>en</language>
    <item>
      <title>How to set up Pint in Docker in less than 5 minutes</title>
      <dc:creator>matiasbenary</dc:creator>
      <pubDate>Wed, 26 Apr 2023 22:29:53 +0000</pubDate>
      <link>https://dev.to/matiasbenary/how-to-set-up-pint-in-docker-in-less-than-5-minutes-3n1o</link>
      <guid>https://dev.to/matiasbenary/how-to-set-up-pint-in-docker-in-less-than-5-minutes-3n1o</guid>
      <description>&lt;p&gt;I have several legacy projects in Laravel and I can't install pint in each one, I want to run pint in each one and make it independent of the system and the projects.&lt;br&gt;
Steps:&lt;br&gt;
1- Create the docker image and install pint&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker run --interactive --tty 
  --volume ~/.composer:/app 
  --volume ${COMPOSER_HOME:-$HOME/.composer}:/tmp 
    composer require laravel/pint
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;command breakdown&lt;/strong&gt;:&lt;br&gt;
 - &lt;strong&gt;interactive&lt;/strong&gt;: creates an interactive session that allows user interaction with the container&lt;br&gt;
 - &lt;strong&gt;tty&lt;/strong&gt;: assigns a tty terminal for the interactive session&lt;br&gt;
-&lt;strong&gt;-volume ~/.composer:/app&lt;/strong&gt;: mounts the ~/.composer directory of the host system to the /app directory of the archive. This allows the container to access the Composer files on the host.&lt;br&gt;
 - &lt;strong&gt;volume ${COMPOSER_HOME:-$HOME/.composer}:/tmp&lt;/strong&gt;: mounts the Composer directory on the host to the /tmp directory of the container. This allows Composer to store temporary files on the host.&lt;br&gt;
&lt;strong&gt;composer require laravel/pint&lt;/strong&gt;: finally, use Composer to install the "laravel/pint" package in the container.&lt;/p&gt;

&lt;p&gt;2- command to execute pint in our project:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker run --rm -v ~/.composer:/app -v $(pwd):/app/project  -w /app composer ./vendor/bin/pint ./project
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;— rm&lt;/strong&gt;: this option tells Docker to delete the container after the command execution is finished.&lt;br&gt;
&lt;strong&gt;-v ~/.composer:/app&lt;/strong&gt;: this option mounts the ~/.composer directory on the host system to the /app directory of the container. This allows the container to access the Composer files on the host.&lt;br&gt;
&lt;strong&gt;-v $(pwd):/app/project&lt;/strong&gt;: this option mounts the current working directory ($(pwd)) of the host system to the /app/project directory of the container. This allows the container to access the project located in the current working directory.&lt;br&gt;
&lt;strong&gt;-w /app&lt;/strong&gt;: this option sets the current working directory inside the container to /app.&lt;br&gt;
&lt;strong&gt;composer&lt;/strong&gt;: this is the name of the container image that will be used to execute the command.&lt;br&gt;
&lt;strong&gt;./vendor/bin/pint ./project&lt;/strong&gt;: this is the command that will be executed inside the container. The pint command is a binary that is installed through the laravel/pint package, which must be available in the composer.json file of the project. This command will be executed in the /app/project directory inside the container.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Plus&lt;/strong&gt;:&lt;br&gt;
Create alias&lt;br&gt;
open ~/.bashrc&lt;br&gt;
add the following line&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;alias pintd='docker run --rm -v ~/.composer:/app -v $(pwd):/app/project  -w /app composer ./vendor/bin/pint ./project'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;save and run source ~/.bashrc&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
