Hello guys.
I need my Dockerfile file to download a file and extract it in the “/var/www/html” directory of the container. I tried in several ways and failed. Apparently this happens but then it seems that everything is excluded. I’ve tried with the command RUN wget , RUN curl , ADD, etc. I wanted you to get the file on the internet and extract it, that’s all. I found some examples on the internet but my code has some error that I did not identify. Below are the 2 files (Dockerfile and docker-compose.yml) that I am using to do this. I just put wordpress as an example.
file: Dockerfile
FROM php:7.4-apache
EXPOSE 80
RUN apt-get update -y && \
apt-get install -y \
libzip-dev \
libpng-dev \
libc-client-dev \
libkrb5-dev --no-install-recommends \
wget ca-certificates
RUN docker-php-ext-configure imap --with-kerberos --with-imap-ssl && \
docker-php-ext-install -j$(nproc) imap
RUN docker-php-ext-install mysqli gd zip
RUN a2enmod rewrite
#COPY www/ /var/www/html/
#RUN chown -R www-data:www-data /var/www/html/
#RUN chmod -R 755 /var/www/html/
#RUN curl -o wordpress.tar.gz https://br.wordpress.org/wordpress-5.7-pt_BR.tar.gz; \
# tar -xzf wordpress.tar.gz -C /var/www/html; \
#RUN tar -xzf wordpress-5.7-pt_BR.tar.gz
#RUN wget -r https://br.wordpress.org/wordpress-5.7-pt_BR.tar.gz && tar -xzf wordpress.tar.gz -C /var/www/html;
#VOLUME /var/www/html
#WORKDIR /var/www/html
#RUN set -ex; \
# curl -o wordpress.tar.gz -SL https://br.wordpress.org/wordpress-5.7-pt_BR.tar.gz; \
# tar -xzf wordpress.tar.gz -C /var/www/html
#RUN tar -xzf wordpress-5.7-pt_BR.tar.gz -C /var/www/html;
#ADD https://br.wordpress.org/wordpress-5.7-pt_BR.tar.gz /var/www/html/
RUN curl -LO http://wordpress.org/latest.tar.gz &&\
tar xvzf latest.tar.gz -C /var/www/html --strip-components=1 &&\
rm latest.tar.gz &&\
chmod -R 755 /var/www/
#RUN curl -o wordpress.tar.gz http://wordpress.org/latest.tar.gz
#RUN tar -xzvf wordpress.tar.gz --strip-components=1 --directory /var/www/html/
#RUN rm wordpress.tar.gz
file: docker-compose.yml
version: '3.9'
services:
wordpress:
build:
context: .
dockerfile: ./Dockerfile
image: test/wordpress
container_name: "wordpress"
restart: "no"
depends_on:
- wordpress-mysql
ports:
- 80:80
volumes:
- "./www/:/var/www/html"
wordpress-mysql:
image: mysql:5.6
container_name: "wordpress-mysql"
restart: "no"
ports:
- 3306
volumes:
- "./mysql:/var/lib/mysql"
environment:
MYSQL_ROOT_PASSWORD: root