Docker on a Macbook M1

  apple-m1, docker, docker-compose, dockerfile, sql

I’ve been having some problems to build with docker compose and dockerfile. There are some errors related to msqltools and sql while I’m building.

Here’s the dockerfile:

FROM ubuntu:18.04

ARG DEBIAN_FRONTEND=noninteractive ARG PHP_VERSION=7.3 ARG
COMPOSER_ALLOW_SUPERUSER=1

  1. Install development packages and clean up apt cache. RUN apt-get update && apt-get install -y –no-install-recommends
    ca-certificates curl
    g++
    git
    libbz2-dev
    libfreetype6-dev
    libicu-dev
    libjpeg-dev
    libmcrypt-dev
    libpng-dev
    libreadline-dev
    sudo
    unzip locales
    zip vim && rm -rf /var/lib/apt/lists/*
    install sqlsrv client RUN apt-get update && apt-get install -y –no-install-recommends
    apt-transport-https ca-certificates gnupg &&
    curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add – &&
    curl https://packages.microsoft.com/config/ubuntu/18.04/prod.list > /etc/apt/sources.list.d/mssql-release.list &&
    apt-get update &&
    ACCEPT_EULA=Y apt-get install -y –no-install-recommends
    msodbcsql17
    mssql-tools
    unixodbc-dev &&
    echo ‘export PATH="$PATH:/opt/mssql-tools/bin"’ >> ~/.bash_profile &&
    echo ‘export PATH="$PATH:/opt/mssql-tools/bin"’ >> ~/.bashrc &&
    apt-get -y autoremove &&
    rm -rf /var/lib/apt/lists/*

install apache RUN apt-get update && apt-get install -y –no-install-recommends
apache2 &&
apt-get -y autoremove &&
rm -rf /var/lib/apt/lists/* &&
mkdir -p /var/www/public &&
a2enmod rewrite COPY ./docker/etc/apache2/sites-available/000-default.conf
/etc/apache2/sites-available/000-default.conf

add PHP repository RUN apt-get update && apt-get install -y –no-install-recommends
software-properties-common &&
LC_ALL=C.UTF-8 add-apt-repository -y -u ppa:ondrej/php &&
apt-get -y autoremove &&
rm -rf /var/lib/apt/lists/*

install PHP RUN apt-get update && apt-get install -y –no-install-recommends
libapache2-mod-php${PHP_VERSION}
php${PHP_VERSION}-bcmath
php${PHP_VERSION}-bz2
php${PHP_VERSION}-cli
php${PHP_VERSION}-common
php${PHP_VERSION}-curl
php${PHP_VERSION}-dba
php${PHP_VERSION}-dev
php${PHP_VERSION}-gd
php${PHP_VERSION}-imap
php${PHP_VERSION}-intl
php${PHP_VERSION}-ldap
php${PHP_VERSION}-mbstring
php${PHP_VERSION}-memcache
php${PHP_VERSION}-mysql
php${PHP_VERSION}-odbc
php${PHP_VERSION}-recode
php${PHP_VERSION}-soap
php${PHP_VERSION}-sqlite
php${PHP_VERSION}-tidy
php${PHP_VERSION}-xml
php${PHP_VERSION}-xmlrpc
php${PHP_VERSION}-xsl
php${PHP_VERSION}-zip
php-pear &&
apt-get -y autoremove &&
rm -rf /var/lib/apt/lists/*

install Microsoft SQL Server Driver for PHP RUN apt-get update && apt-get install -y –no-install-recommends
g++
make &&
pecl install sqlsrv pdo_sqlsrv &&
echo "extension=sqlsrv.so" >> /etc/php/${PHP_VERSION}/mods-available/sqlsrv.ini &&
echo "extension=pdo_sqlsrv.so" >> /etc/php/${PHP_VERSION}/mods-available/pdo_sqlsrv.ini &&
phpenmod sqlsrv pdo_sqlsrv &&
apt-get -y remove g++ make &&
apt-get -y autoremove &&
rm -rf /var/lib/apt/lists/*

Instalação e configuração do XDebug RUN apt-get update && apt-get install -y –no-install-recommends php-xdebug
&& echo "zend_extension=/usr/lib/php/20170718/xdebug.so" > /etc/php/${PHP_VERSION}/mods-available/xdebug.ini
&& echo "xdebug.remote_enable=on" >> /etc/php/${PHP_VERSION}/mods-available/xdebug.ini
&& echo "xdebug.remote_handler=dbgp" >> /etc/php/${PHP_VERSION}/mods-available/xdebug.ini
&& echo "xdebug.remote_port=9000" >> /etc/php/${PHP_VERSION}/mods-available/xdebug.ini
&& echo "xdebug.remote_autostart=on" >> /etc/php/${PHP_VERSION}/mods-available/xdebug.ini
&& echo "xdebug.remote_connect_back=0" >> /etc/php/${PHP_VERSION}/mods-available/xdebug.ini
&& echo "xdebug.idekey=PHPSTORM" >> /etc/php/${PHP_VERSION}/mods-available/xdebug.ini
&& echo "xdebug.remote_host=host.docker.internal" >> /etc/php/${PHP_VERSION}/mods-available/xdebug.ini
&& echo "xdebug.mode=debug" >> /etc/php/${PHP_VERSION}/mods-available/xdebug.ini
&& echo "xdebug.client_host=host.docker.internal" >> /etc/php/${PHP_VERSION}/mods-available/xdebug.ini
&& echo "xdebug.remote_log=/var/www/html/xdebug.log" >> /etc/php/${PHP_VERSION}/mods-available/xdebug.ini
&& echo "xdebug.default_enable=on" >> /etc/php/${PHP_VERSION}/mods-available/xdebug.ini

install composer RUN curl -sS https://getcomposer.org/installer | php — –install-dir=/usr/local/bin –filename=composer

  1. Apache configs + document root.
    RUN echo "ServerName laravel-app.local" >> /etc/apache2/apache2.conf
    ENV APACHE_DOCUMENT_ROOT=/var/www/public
    RUN sed -ri -e ‘s!/var/www/public!${APACHE_DOCUMENT_ROOT}!g’ /etc/apache2/sites-available/.conf
    RUN sed -ri -e ‘s!/var/www/!${APACHE_DOCUMENT_ROOT}!g’ /etc/apache2/apache2.conf /etc/apache2/conf-available/
    .conf

  2. mod_rewrite for URL rewrite and mod_headers for .htaccess extra headers like Access-Control-Allow-Origin- RUN a2enmod rewrite headers

WORKDIR /var/www/public

EXPOSE 80

  1. Start with base PHP config, then add extensions.
    RUN mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini"

CMD ["/usr/sbin/apache2ctl", "-D", "FOREGROUND"]

This was compatible with my old Macbook Air 2018 and still compatible with my colleagues pc’s. Can anyone tell me what can I do to fix it?

Source: Docker Questions

LEAVE A COMMENT