<?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: Lukas Hron</title>
    <description>The latest articles on DEV Community by Lukas Hron (@lukashron).</description>
    <link>https://dev.to/lukashron</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1431599%2Ffdbd7cf9-7401-4b59-ba2c-2ccdb696e4f2.jpg</url>
      <title>DEV Community: Lukas Hron</title>
      <link>https://dev.to/lukashron</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/lukashron"/>
    <language>en</language>
    <item>
      <title>Symfony performance tips</title>
      <dc:creator>Lukas Hron</dc:creator>
      <pubDate>Tue, 17 Nov 2026 13:09:30 +0000</pubDate>
      <link>https://dev.to/lukashron/symfony-performance-tips-3822</link>
      <guid>https://dev.to/lukashron/symfony-performance-tips-3822</guid>
      <description>&lt;p&gt;Building large services with many dependencies brings a whole range of performance problems. Initializing and loading such a service costs us memory, CPU, and request processing time. Let's look at three basic techniques for optimizing services in Symfony while keeping the code clean.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Divide and conquer
&lt;/h2&gt;

&lt;p&gt;Symfony can inject a service directly into a controller method argument. Don't build a "god service". Split operations into separate micro-services, each with a single responsibility. Every service then calls only what it really needs. As a bonus you get a better structure, cleaner code, and easier refactoring down the road.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="k"&gt;final&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;ArticleController&lt;/span&gt; &lt;span class="k"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;AbstractController&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;#[Route('/article', methods: ['POST'])]&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;ArticleCreateService&lt;/span&gt; &lt;span class="nv"&gt;$service&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Response&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// ...&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="c1"&gt;#[Route('/article/{id}', methods: ['PUT'])]&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;update&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nv"&gt;$id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;ArticleUpdateService&lt;/span&gt; &lt;span class="nv"&gt;$service&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Response&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// ...&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="c1"&gt;#[Route('/article/{id}', methods: ['DELETE'])]&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;delete&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nv"&gt;$id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;ArticleDeleteService&lt;/span&gt; &lt;span class="nv"&gt;$service&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Response&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// ...&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  2. #[Lazy] — defer creating a service until you need it
&lt;/h2&gt;

&lt;p&gt;Sometimes you have to keep a service in the constructor, but you only use it under certain conditions. For example ArticleCreateService, which can also process an illustrative image from a form — but only if the user attached one. Thanks to the #[Lazy] attribute, the DIC creates a proxy for the service and initializes the real service only at the moment we actually reach for it in the code.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="k"&gt;use&lt;/span&gt; &lt;span class="nc"&gt;Symfony&lt;/span&gt;\&lt;span class="nc"&gt;Component&lt;/span&gt;\&lt;span class="nc"&gt;DependencyInjection&lt;/span&gt;\&lt;span class="nc"&gt;Attribute&lt;/span&gt;\&lt;span class="nc"&gt;Lazy&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;final&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;ArticleCreateService&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;__construct&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="c1"&gt;#[Lazy]&lt;/span&gt;
        &lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="k"&gt;readonly&lt;/span&gt; &lt;span class="nc"&gt;ImageUploadService&lt;/span&gt; &lt;span class="nv"&gt;$imageUploader&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;ArticleData&lt;/span&gt; &lt;span class="nv"&gt;$data&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Article&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nv"&gt;$article&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Article&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$data&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;title&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$data&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;content&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$data&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;image&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="c1"&gt;// ImageUploadService se instancuje teprve tady&lt;/span&gt;
            &lt;span class="nv"&gt;$article&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;setImagePath&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
                &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;imageUploader&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;upload&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$data&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;image&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;

        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nv"&gt;$article&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When the article has no image, ImageUploadService and its dependencies are never created.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Service locator
&lt;/h2&gt;

&lt;p&gt;An ideal tool when, for example, we're writing a service to process data sources and need to call a parser based on the data type.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;__construct&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="c1"&gt;#[AutowireLocator([&lt;/span&gt;
        &lt;span class="nc"&gt;XmlParserService&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="k"&gt;class&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="nc"&gt;DbParserService&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="k"&gt;class&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="nc"&gt;MdParserService&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="k"&gt;class&lt;/span&gt;
    &lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="k"&gt;readonly&lt;/span&gt; &lt;span class="nc"&gt;ContainerInterface&lt;/span&gt; &lt;span class="nv"&gt;$parsers&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the handle() method we then call the right parser based on the data type.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;handle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="nv"&gt;$payload&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;array&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nv"&gt;$parserClassName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;getParserClassNameByData&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$payload&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="nv"&gt;$parser&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;parsers&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$parserClassName&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nv"&gt;$parser&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;toArray&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$payload&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;All three parsers are registered, but only the one we actually need gets instantiated.&lt;/p&gt;

&lt;p&gt;All three approaches aim at the same thing — not paying for creating services you won't use in a given request anyway.&lt;/p&gt;

</description>
      <category>symfony</category>
      <category>php</category>
      <category>performance</category>
    </item>
    <item>
      <title>Problem with Installing ImageMagick for PHP 8.4 in Docker.</title>
      <dc:creator>Lukas Hron</dc:creator>
      <pubDate>Thu, 27 Feb 2025 16:36:35 +0000</pubDate>
      <link>https://dev.to/lukashron/problem-with-installing-imagemagick-for-php-84-in-docker-223f</link>
      <guid>https://dev.to/lukashron/problem-with-installing-imagemagick-for-php-84-in-docker-223f</guid>
      <description>&lt;p&gt;If you use the ImageMagick extension and plan to upgrade to PHP 8.3 or 8.4, you will encounter an issue with installation via PECL. Unfortunately, the PECL package is not compatible with these PHP versions, causing the installation to fail. As an alternative, you can build the source code directly from the repository, which allows you to bypass this issue and successfully configure ImageMagick.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;RUN apt-get update &amp;amp;&amp;amp; apt-get install -y \
    imagemagick \
    libmagickwand-dev \
    &amp;amp;&amp;amp; git clone https://github.com/Imagick/imagick --depth 1 /tmp/imagick \
    &amp;amp;&amp;amp; cd /tmp/imagick \
    &amp;amp;&amp;amp; phpize &amp;amp;&amp;amp; ./configure \
    &amp;amp;&amp;amp; make \
    &amp;amp;&amp;amp; make install \
    &amp;amp;&amp;amp; apt-get clean

RUN docker-php-ext-enable imagick
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>php</category>
      <category>docker</category>
      <category>imagemagick</category>
    </item>
    <item>
      <title>Basic Protection Against Max Execution Time Limit</title>
      <dc:creator>Lukas Hron</dc:creator>
      <pubDate>Wed, 25 Sep 2024 10:57:30 +0000</pubDate>
      <link>https://dev.to/lukashron/basic-protection-against-max-execution-time-limit-ecj</link>
      <guid>https://dev.to/lukashron/basic-protection-against-max-execution-time-limit-ecj</guid>
      <description>&lt;p&gt;Anyone who has dealt with importing or exporting data has likely encountered the problem of a script running into a short execution time limit. The quickest solution often involves adjusting the PHP configuration or completely disabling the limit at the beginning of the script. However, extending the execution time significantly or disabling it altogether introduces security risks. An unstoppable background script can lead to excessive resource consumption.&lt;/p&gt;

&lt;p&gt;When processing tasks over iterations, it's possible to monitor individual passes in time and attempt to gracefully terminate execution before the time limit expires.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// initialize basic variables for further work
$maxExecutionTime = (int)ini_get('max_execution_time');
$estimateCycleTime = 0;
$startTime = microtime(true);

// For demonstration purposes, we use an "infinite" loop with a simulated task lasting 10 seconds
while (true) {
   sleep(10);

   // Calculate the current runtime
   $currentRunTime = microtime(true) - $startTime;

   // Termination can be done either with a fixed constant
   // or by measuring the time of one pass and trying to use
   // the longest possible segment of the runtime
   // limit (has its problem).
   if ($estimateCycleTime === 0) {
       $estimateCycleTime = $currentRunTime;
   }

   // Check if the iteration stop time is approaching.
   // Subtract the time of one pass, which likely won't fit
   // within the window. 
   if (($maxExecutionTime - $estimateCycleTime) &amp;lt; $currentRunTime) {
       echo 'Time is end';
       break;
   }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Early termination based on the calculation of one pass is suitable for cases where there are a large number of passes that need to be processed in as few new executions as possible, and each operation in one pass is similarly time-consuming. If individual passes differ in their time requirements, a coefficient must be added to the pass time. Another option is to use a predefined time:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$beforeEndTime = 1;

if (($maxExecutionTime - $beforeEndTime) &amp;lt; $currentRunTime) {
    echo 'Time is end';
    break;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the script continues after iteration, such as closing connections to API endpoints, closing files, or performing other operations, it's essential to remember to add this time.&lt;/p&gt;

</description>
      <category>php</category>
    </item>
    <item>
      <title>Convert UTF8 to Windows 1250</title>
      <dc:creator>Lukas Hron</dc:creator>
      <pubDate>Thu, 01 Aug 2024 14:04:14 +0000</pubDate>
      <link>https://dev.to/lukashron/convert-utf8-to-windows-1250-2o64</link>
      <guid>https://dev.to/lukashron/convert-utf8-to-windows-1250-2o64</guid>
      <description>&lt;p&gt;When working with different encodings, it may be necessary to convert text from one format to another. If you need to convert text from UTF-8 encoding to Windows-1250 using PHP, the script below can help you. This script performs the conversion and offers the output text for download.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$fileName = 'encoded.txt';
$inputText = 'Example text';

setlocale(LC_CTYPE, 'cs_CZ');
$output = iconv('UTF-8', 'Windows-1250//TRANSLIT', $inputText);

ob_clean();
header("Expires: Mon, 1 Apr 1970 05:00:00 GMT");
header(sprintf("Last-Modified: %s GMT", gmdate("D,d M YH:i:s")));
header("Pragma: no-cache");
header(sprintf("Content-type: application/octet-stream; charset=windows-1250; name=%s", $fileName));
header(sprintf("Content-Disposition: attachment; filename=%s", $fileName));
header(sprintf("Content-Length: %s", strlen($output)));
header("Content-Transfer-Encoding: binary");
header("Content-Description: Export dat");
echo $output;
exit;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This tool makes it easier to work with texts in different encodings, especially if you're dealing with Czech characters or other Central European languages. I hope you find it useful!&lt;/p&gt;

</description>
      <category>php</category>
      <category>utf8</category>
      <category>windows1250</category>
    </item>
    <item>
      <title>Installing NPM with Docker</title>
      <dc:creator>Lukas Hron</dc:creator>
      <pubDate>Wed, 17 Apr 2024 14:24:58 +0000</pubDate>
      <link>https://dev.to/lukashron/installing-npm-with-docker-35ib</link>
      <guid>https://dev.to/lukashron/installing-npm-with-docker-35ib</guid>
      <description>&lt;p&gt;How to install NPM into my custom Docker container? We will show three basic ways in DockerFile.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;First and simple way&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;FROM debian:11-slim
RUN apt-get update &amp;amp;&amp;amp; apt-get install -y wget gnupg g++ apt-utils curl git &amp;amp;&amp;amp; apt-get clean

######################

RUN apt-get update &amp;amp;&amp;amp; apt-get install -y npm &amp;amp;&amp;amp; apt-get clean
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Installing with NVM tool&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;FROM debian:11-slim
RUN apt-get update &amp;amp;&amp;amp; apt-get install -y wget gnupg g++ apt-utils curl git &amp;amp;&amp;amp; apt-get clean

######################

ENV NODE_VERSION 20.12.2
ENV NVM_DIR /usr/local/nvm

RUN mkdir -p $NVM_DIR

RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash

RUN . "${NVM_DIR}/nvm.sh" \
    &amp;amp;&amp;amp; nvm install $NODE_VERSION \
    &amp;amp;&amp;amp; nvm alias default $NODE_VERSION \
    &amp;amp;&amp;amp; nvm use $NODE_VERSION

ENV PATH="${NVM_DIR}/versions/node/v${NODE_VERSION}/bin:${PATH}"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Installing from Debian Nodesource resources&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;FROM debian:11-slim
RUN apt-get update &amp;amp;&amp;amp; apt-get install -y wget gnupg g++ apt-utils curl git &amp;amp;&amp;amp; apt-get clean

######################

RUN curl -sL https://deb.nodesource.com/setup_16.x | bash - \
    &amp;amp;&amp;amp; apt-get update &amp;amp;&amp;amp; apt-get install -y nodejs \
    &amp;amp;&amp;amp; apt-get clean

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>npm</category>
      <category>docker</category>
    </item>
  </channel>
</rss>
