Running TYPO3 in Docker via wget '' - php

I'm running few Docker Containers view at the Code below. I would like to integrate the TYPO3 via w get but get an ERROR: Service 'app' failed to build: ADD failed: stat /mnt/sda1/var/lib/docker/tmp/docker-builder400003814/|: no such file or directory how can i solve it? and move the necessary folders into my www/ path thanks :)
docker-compose up -d
`docker-compose.yml`
version: '2'
services:
version: '2'
services:
#######################################
# PHP application Docker container
#######################################
app:
build:
context: .
dockerfile: Dockerfile
links:
- mysql
ports:
- "8000:80"
#######################################
# MySQL server
#######################################
mysql:
build:
context: docker/mysql/
dockerfile: MySQL-5.7.Dockerfile
restart: always
env_file:
- etc/environment.yml
networks:
- php-network
#######################################
# PHP MY ADMIN
#######################################
myphpadmin:
build:
context: docker/myphpadmin
dockerfile: Dockerfile
restart: always
links:
- mysql
ports:
- 8080:80
environment:
- PMA_HOST=mysql
- VIRTUAL_PORT=80
networks:
- php-network
networks:
php-network:
driver: bridge
`Dockerfile` for PHP & APACHE
FROM webdevops/php-apache-dev:ubuntu-16.04
ENV PROVISION_CONTEXT "development"
# Configure volume/workdir
WORKDIR /app/
Typo3 `Dockerfile`
FROM ubuntu:latest
ENV TYPO3_VERSION 7.6.16
# Install apache, PHP, and supplimentary programs. openssh-server, curl, and lynx-cur are for debugging the container.
RUN apt-get update && apt-get -y upgrade && DEBIAN_FRONTEND=noninteractive apt-get -y install \
apache2 php7.0 php7.0-mysql libapache2-mod-php7.0 curl lynx-cur php7.0-curl php7.0-gd php-imagick php7.0-soap php7.0-xml php7.0-zip
# Enable apache mods.
RUN a2enmod php7.0
RUN a2enmod rewrite
# Update the PHP.ini file, enable <? ?> tags and quieten logging.
RUN sed -i "s/short_open_tag = Off/short_open_tag = On/" /etc/php/7.0/apache2/php.ini
RUN sed -i "s/error_reporting = .*$/error_reporting = E_ERROR | E_WARNING | E_PARSE/" /etc/php/7.0/apache2/php.ini
ADD https://get.typo3.org/7.6 | tar -xzf - && \
RUN cd /var/www/html && \
ln -s typo3_src-* typo3_src && \
ln -s typo3_src/index.php && \
ln -s typo3_src/typo3 && \
ln -s typo3_src/_.htaccess .htaccess && \
mkdir typo3temp && \
mkdir typo3conf && \
mkdir fileadmin && \
mkdir uploads && \
touch FIRST_INSTALL && \
chown -R www-data. .
# Manually set up the apache environment variables
ENV APACHE_RUN_USER www-data
ENV APACHE_RUN_GROUP www-data
ENV APACHE_LOG_DIR /var/log/apache2
ENV APACHE_LOCK_DIR /var/lock/apache2
ENV APACHE_PID_FILE /var/run/apache2.pid
# Expose apache.
EXPOSE 80
# Copy this repo into place.
ADD www /var/www/site
# Update the default apache site with the config we created.
ADD etc/apache-config.conf /etc/apache2/sites-enabled/000-default.conf
# By default start up apache in the foreground, override with /bin/bash for interative.
CMD /usr/sbin/apache2ctl -D FOREGROUND

That is however not really TYPO3 related.
I would suggest that you take a look at https://github.com/webdevops/TYPO3-docker-boilerplate which is well tested and just works out of the box.

Related

Dockerizing an already existing Symfony project

I am trying to automate the development of a project I am currently working on by creating a container on Docker that is composed of mysql, php and nginx to run a Symfony project. Here is my docker-compose.yml
services:
database:
container_name: database
image: mysql:8.0
command: --default-authentication-plugin=mysql_native_password
environment:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: rapidhcm
MYSQL_USER: admin
MYSQL_PASSWORD: password
ports:
- '4306:3306'
volumes:
- ./docker/mysql:/var/lib/mysql
php:
container_name: php
build:
context: .
ports:
- '9000:9000'
volumes:
- ./rapid-backend:/var/www/public
depends_on:
- database
nginx:
container_name: nginx
image: nginx:stable-alpine
ports:
- '8080:80'
volumes:
- ./rapid-backend:/var/www/public
- ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf
depends_on:
- php
- database
And here is my Dockerfile:
FROM php:8.0-fpm
RUN apt update \
&& apt install -y zlib1g-dev g++ git libicu-dev zip libzip-dev zip \
&& docker-php-ext-install intl opcache pdo pdo_mysql \
&& pecl install apcu \
&& docker-php-ext-enable apcu \
&& docker-php-ext-configure zip \
&& docker-php-ext-install zip
WORKDIR /var/www/html
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
RUN curl -sS https://get.symfony.com/cli/installer | bash
RUN mv /root/.symfony5/bin/symfony /usr/local/bin/symfony
RUN git config --global user.email "email#email.com" \
&& git config --global user.name "Damian Kowalski"
The Dockerfile and docker-compose.yml files are in the root folder of the project, however the Symfony index.php file is situated in ./rapid-backend/public/index.php. How can I indicate that I want to serve that php file?
You would typically use only two containers: one for the database and one for the php-enabled web server.
You start from an php+apache image or an nginx image with php installed. Then you can bind-mount the web server's configuration files just as you did in your docker-compose.yaml for the nginx container.
You'd have something like this in your Dockerfile:
FROM php:8.2-apache AS production
ADD default.conf /etc/apache2/sites-available/default.conf
RUN # <...>
# Install tools and PHP dependencies
# apt-get update && \
# apt-get install -y <...> && \
# Configure docker php extensions, see image documenation on dockerhub
# docker-php-ext-configure <...> && \
# docker-php-ext-install <...> && \
# Maybe you want xdebug? In that case you'll also want to copy a .ini file
# pecl install xdebug && \
# Cleanup
# docker-php-source delete && \
# Install latest composer 2
# curl https://getcomposer.org/composer-2.phar > /usr/local/bin/composer && \
# chmod +x /usr/local/bin/composer && \
# Enable some apache mods if needed
# a2enmod rewrite headers expires xsend && \
# Some more cleanup if needed
# apt-get remove -y <...> && \
# apt-get clean
# If this image is to be used in a development environment, here you may want to create a user that you'll tell Apache to use with APACHE_RUN_USER, using the same UID as your own user on your host, so that you can bind-mount your sources in your docker-compose.yaml file without having permission issues.
# If however this is a deployment image, here you will probably want to "COPY" your source code in the image and to "RUN composer install".
with the appropriate apache configuration file default.conf that exposes your index.php (see the Symfony documentation at https://symfony.com/doc/current/setup/web_server_configuration.html for example configuration files).
Then your web server service in docker-compose.yaml could look like:
web-server:
build:
context: .
ports:
- '8080:80'
# If this is a dev environment, bind mount your source code, maybe also
# have a "user: ..." option here if you created one in the Dockerfile
volumes:
- ./rapid-backend:/var/www/public
It's a pretty open question but I hope this is a push in the right direction. Starting from here you can use docker-compose exec to run a bash shell inside your web server, and use composer to install Symfony and initialize your project.

Opening Docker container port on localhost in browser returns empty response

I'm trying to run a web project from a Docker container,
when I Dockerize the application on a macBook with an intel chip, everything runs fine and I can make a call to the Docker container. But when I run the same project, with the same setup on my M2 MacBook Air, the browser returns an empty response.
("this page isn't working" --> in Chrome)
This happens even though the containers appear to be running...
(Both containers are green lit up --> in Docker Desktop)
The container makes use of an Nginx service and a php service. The .yml file looks as below:
Docker-compose.yml
version: '3'
services:
#PHP Service
app:
build:
context: .
dockerfile: Dockerfile
image: php:8.0.6-fpm
container_name: Asset-Service
restart: unless-stopped
tty: true
environment:
SERVICE_NAME: Asset-Service
SERVICE_TAGS: dev
working_dir: /var/www
volumes:
- ./:/var/www
- ./php/local.ini:/usr/local/etc/php/conf.d/local.ini
networks:
- app-network
#Nginx Service
webserver:
image: nginx:stable
container_name: Asset-Web-Server
restart: unless-stopped
tty: true
ports:
- "8087:80"
- "4487:443"
volumes:
- ./:/var/www
- ./nginx/conf.d/:/etc/nginx/conf.d/
networks:
- app-network
#Docker Networks
networks:
app-network:
driver: bridge
#Volumes
volumes:
dbdata:
driver: local
My Dockerfile is the following, even though I don't think that this file causes the problem:
Dockerfile
FROM php:8.0.6-fpm
# Copy composer.lock and composer.json
COPY composer.lock composer.json /var/www/
# Set working directory
WORKDIR /var/www
# Install dependencies
USER root
RUN apt-get update && apt-get install -y \
mariadb-client-10.3 \
libcurl4-openssl-dev \
pkg-config \
libssl-dev \
libpng-dev \
libzip-dev \
libonig-dev \
libjpeg62-turbo-dev \
libfreetype6-dev \
locales \
zip \
jpegoptim optipng pngquant gifsicle \
vim \
unzip \
git \
curl \
nano
RUN pecl uninstall mongodb
RUN pecl install mongodb
RUN echo "extension=mongodb.so" >> /usr/local/etc/php/conf.d/mongodb.ini
# Clear cache
## RUN apt-get clean && rm -rf /var/lib/apt/lists/*
# Install extensions
RUN docker-php-ext-install pdo_mysql mbstring zip exif pcntl
RUN docker-php-ext-configure gd --with-freetype=/usr/include/ --with-jpeg=/usr/include/
RUN docker-php-ext-install gd
#RUN docker-php-ext-enable mongodb
# Install composer
## RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
# Add user for laravel application
RUN groupadd -fg 1000 www
RUN id -u 1000 >/dev/null 2>&1 || useradd -u 1000 -ms /bin/bash -g www www
# Copy existing application directory contents
COPY . /var/www
# Copy existing application directory permissions
COPY --chown=www:www . /var/www
# Change current user to www
USER www
# Expose port 9000 and start php-fpm server
EXPOSE 9000
CMD ["php-fpm"]
The container logs look normal and the ports in the inspect tab show 0.0.0.0:8087 and 0.0.0.0:4487.
Is this a recurring issue with the apple silicon version of Docker,
and is there anything I can do about it?
I have already tried to replicate the issue on an Intel macBook, but got the desired result instead of the empty response.
On my M2 I tried reinstalling Docker and rebuilding the containers but this didn't seem to fix anything...
Nevermind this issue.
This problem occurred when trying to build the containers from the Desktop folder.

docker-compose.yml file and Dockerfile for mysql php apache application

I want to run my application in a docker container. I am able to run my PHP application in a docker container but I want to add mysql in my application and restore my sql dump in my database. And I want my application code to be cloned by dockerfile and httpd configuration with dockerfile itself.
here is my docker file
FROM centos:centos7
RUN yum -y update \
&& yum --setopt=tsflags=nodocs -y install \
gcc \
httpd \
mod_ssl \unzip \
&& rm -rf /var/cache/yum/* \
&& yum clean all
RUN rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm
RUN rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
RUN yum remove php-cli php-common
RUN yum -y install php55w \
php55w-opcache \
php55w-xml \
php55w-mcrypt \
php55w-gd \
php55w-devel \
php55w-mysqlnd \
php55w-intl \
php55w-mbstring \
RUN yum -y install git
RUN git clone
https://USERNAME:PASSWORD#gitlab.com/xxxxxxxxxxx/Product/yyyyyyyyyyy.git
abc;
RUN rm -rf /var/cache/yum/*
RUN yum clean all
EXPOSE 80
#ADD ./abc/ /var/www/html/
COPY /abc/abclive/gitlab.abc/dev/ /var/www/html/
#WORKDIR /var/www/html/abc/abclive/gitlab.abc/dev/
ENV APACHE_DOCUMENT_ROOT /var/www/html/abc/abclive/gitlab.abc/dev/
WORKDIR /var/www/html/abc/abclive/gitlab.abc/dev/
CMD ["/usr/sbin/httpd", "-D","FOREGROUND"]
here is my docker-compose.yml
version: '3'
services:
web:
build: .
ports:
- "8090:80"
centos:
image: "centos:centos7"
# links:
# - db
# volumes:
# - .:/newvolebs
#db:
# image: "mysql:5.6"
# volumes:
# - newvolebs:/var/lib/mysql/data
# networks:
# - overlay
# environment:
# MYSQL_ROOT_PASSWORD: PASSWORD
# MYSQL_DATABASE: DATABASENAME
i have created one ebs volume attached it with my instance and make it usable with name "newvolebs"
how to mount it in my application database.
Thanks in advance.

docker-compose volume mount is empty when using docker toolbox (windows)

I am trying to dockerise my laraver 5.5 application using docker-compose.
Here's my docker-compose.yml file definition:
version: '2.1'
services:
# The Database
database:
image: mysql:5.7
restart: always
healthcheck:
test: ["CMD", "mysqladmin" ,"ping", "-h", "localhost"]
timeout: 20s
retries: 10
environment:
- "MYSQL_DATABASE=myapp"
- "MYSQL_USER=myapp"
- "MYSQL_PASSWORD=123456"
- "MYSQL_ROOT_PASSWORD=secret"
ports:
- "33061:3306"
# The Application
app:
depends_on:
database:
condition: service_healthy
build:
context: ./
dockerfile: ./docker-compose/app.dockerfile
volumes:
- ./:/var/www/html
environment:
- "DB_CONNECTION=mysql"
- "DB_HOST=database"
- "DB_PORT=3306"
- "DB_DATABASE=myapp"
- "DB_USERNAME=myapp"
- "DB_PASSWORD=123456"
ports:
- "8080:80"
and this is my ./docker-compose/app.dockerfile:
# Base image
FROM php:7.1-apache
# Configure system
RUN apt-get update && apt-get install -y \
libmcrypt-dev \
mysql-client \
zlib1g-dev \
--no-install-recommends \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
&& docker-php-ext-install mcrypt pdo_mysql
# Add php.ini and apache2.conf
COPY docker-compose/php.ini $PHP_INI_DIR/php.ini
COPY docker-compose/apache2.conf /etc/apache2/apache2.conf
# Configuring Apache
RUN rm -rf /etc/apache2/sites-available/* \
&& rm -rf /etc/apache2/sites-enabled/*
# Enable rewrite module
RUN a2enmod rewrite
# Download and install composer globally
RUN curl -s http://getcomposer.org/installer | php \
&& mv composer.phar /usr/local/bin/composer
# Add vendor binaries to PATH
ENV PATH=/var/www/html/vendor/bin:$PATH
I use the following command to start up my stack:
docker-compose -d --build via the Docker Quickstart Terminal on my Windows 10.
Everything builds fine and runs (I checked via docker-compose ps). When I visit the app url, I am getting forbidden error from apache, so I decided to login to the container using docker exec -it my_app_1 /bin/bash command and I went into /var/www/html directory and noticed that it's empty.
Doesn't volume mounting works in windows?

Docker container from image created by build: is working but not working from pulled image

I have built an image for my app with apache, container created from it is working just fine. I am able to see the page on localhost. (file #1: docker-compose.yml)
I push image to docker hub
I recreate a container using another (file #2: docker-compose-prod.yml) for the same app and it's exited immediately without any error, container output was:
Module rewrite already enabled
httpd (pid 1) already running
Here is app service described in docker-compose.yml file #1 which I used for build:
app:
build: .
links:
- db
- memcache:memcached
- search
ports:
#- 8080:80 # when varnish enabled
- 80:80
restart: always
environment:
DB_HOST: db:3306
DB_PASSWORD: *****
SEARCH_HOST: search:9312
MEMCACHE_HOST: memcache:11211
Here is docker-compose-prod.yml, file #2 I used for deployment which contains problem:
app:
image: vendor/app
#restart: always
links:
- db
- memcache:memcached
- search
ports:
#- 8080:80 # when varnish enabled
- 80:80
environment:
DB_HOST: db:3306
DB_PASSWORD: *****
SEARCH_HOST: search:9312
MEMCACHE_HOST: memcache:11211
#networks:
#- proxy
#- backend
Containers of next services are always up and running:
- db
- memcache:memcached
- search
Some details:
I run docker-compose.yml (file#1) from within app directory:
/home/user/app1$ docker-compose up -d
and second file from another directory
/home/user/app2$ docker-compose -f docker-compose-prod.yml up -d
Here is Dockerfile:
FROM ubuntu:trusty
MAINTAINER vendor
# Install base packages
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get -yq install \
curl \
apache2 \
libapache2-mod-php5 \
php5-mysql \
php5-mcrypt \
php5-gd \
php5-curl \
php-pear \
php5-memcache \
php-apc && \
rm -rf /var/lib/apt/lists/*
#ENV ALLOW_OVERRIDE **False**
RUN /usr/sbin/php5enmod mcrypt
RUN echo "ServerName localhost" >> /etc/apache2/apache2.conf && \
sed -i "s/variables_order.*/variables_order = \"EGPCS\"/g" /etc/php5/apache2/php.ini
# Add image configuration and scripts
ADD run.sh /run.sh
RUN chmod 755 /*.sh
# Configure /app folder with sample app
RUN mkdir -p /app && rm -fr /var/www/html && ln -s /app /var/www/html
WORKDIR /app
ADD . /app
RUN chmod 0777 -R /var/www/html/app/tmp
RUN ln -sf /dev/stderr /var/www/html/app/tmp/logs/error.log
RUN ln -sf /dev/stdout /var/www/html/app/tmp/logs/debug.log
RUN chown www-data:www-data /app -R
# should not be run inside container
#RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
#RUN /usr/local/bin/composer install
#RUN php vendor/bin/phinx migrate
EXPOSE 80
CMD ["/run.sh"]
And run.sh
#!/bin/bash
if [ "$ALLOW_OVERRIDE" = "**False**" ]; then
unset ALLOW_OVERRIDE
else
sed -i "s/AllowOverride None/AllowOverride All/g" /etc/apache2/apache2.conf
a2enmod rewrite
fi
source /etc/apache2/envvars
exec apache2 -D FOREGROUND
It happens because really
Module rewrite already enabled
Why does it happen?
When you create container rewrite_module is disabled. And run.sh enable it.
Later, you stop (but not remove) container, and run it again. But run.sh runs everytime when container is starts. And run.sh are trying to load this module again and you receive the error.
You can ignore the error or you can modify run.sh something like:
#!/bin/bash
if [ "$ALLOW_OVERRIDE" = "**False**" ]; then
unset ALLOW_OVERRIDE
else
sed -i "s/AllowOverride None/AllowOverride All/g" /etc/apache2/apache2.conf
if [! httpd -M | grep rewrite_module]; then
a2enmod rewrite;
fi;
fi
source /etc/apache2/envvars
apache2 -D FOREGROUND
I hope I helped you.
Finally I've got it working!
Solution:
# Apache gets grumpy about PID files pre-existing
I added to run.sh following line:
rm -f /var/run/apache2/apache2.pid
See https://github.com/docker-library/php/issues/187
and https://github.com/docker-library/php/blob/bdfd0fc1d19102cd6f951614072a51eabf7191bf/5.6/apache/apache2-foreground

Categories