lima-city: Webhosting, Domains und Cloud
1 Pluspunkt 0 Minuspunkte

Wie kann ich in einem Dockerfile eine Datei bearbeiten? Ich würde gerne diesen Text

server {
        listen 80 default_server;
        root /var/www/html;
        index index.php index.html index.htm index.nginx-debian.html;
        server_name _;
        location / {
                try_files $uri $uri/ =404;
        }
        location ~ \.php$ {
                include snippets/fastcgi-php.conf;
                fastcgi_pass unix:/run/php/php8.1-fpm.sock;
        }
        # deny access to .htaccess files
        location ~ /\.ht {
               deny all;
        }
}

in die Datei 

/etc/nginx/sites-available/default

einfügen.

von  

1 Antwort

0 Pluspunkte 0 Minuspunkte

Das kannst du mit einem EOF Block.

RUN cat <<EOF > /etc/nginx/sites-available/default
server {
        listen 80 default_server;
        root /var/www/html;
        index index.php index.html index.htm index.nginx-debian.html;
        server_name _;
        location / {
                try_files $uri $uri/ =404;
        }
        location ~ \.php$ {
                include snippets/fastcgi-php.conf;
                fastcgi_pass unix:/run/php/php8.1-fpm.sock;
        }
        # deny access to .htaccess files
        location ~ /\.ht {
               deny all;
        }
}
EOF
von (699 Punkte)