Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ubuntu vs Alpine as base image #39

Open
Rozkalns opened this issue Oct 2, 2018 · 0 comments
Open

Ubuntu vs Alpine as base image #39

Rozkalns opened this issue Oct 2, 2018 · 0 comments

Comments

@Rozkalns
Copy link

Rozkalns commented Oct 2, 2018

Do you have in mind to update this course using Alpine as base image?
Or what is the reason why you choose to use Ubuntu in first place?

I followed your course, but I wanted to make it with Alpine as base, I had some trouble with PHP-FPM and Nginx configuration, so I found some DockerImages online, slapped things together, and at least PHP with Nginx now works :)

FROM alpine:3.8

MAINTAINER Roberts Rozkalns

RUN apk add --no-cache \
    gnupg tzdata \
    && ln -snf /usr/share/zoneinfo/UTC /etc/localtime \
    && echo "UTC" > /etc/timezone \
    && apk del tzdata

RUN apk add --no-cache \
    curl zip unzip git supervisor sqlite \
    nginx php7-fpm php7-cli \
    php7-pgsql php7-sqlite3 php7-gd \
    php7-curl php7-memcached \
    php7-imap php7-pdo php7-pdo_mysql php7-mbstring \
    php7-xml php7-zip php7-bcmath php7-soap \
    php7-intl php7-xdebug \
    php7-phar php7-json \
    && php -r "readfile('http://getcomposer.org/installer');" | php -- --install-dir=/usr/bin/ --filename=composer \
    && for dir in php nginx; do mkdir -p /run/${dir}; done

# Add user
RUN set -x ; \
  addgroup -g 82 -S www-data ; \
  adduser -u 82 -D -S -G www-data www-data

# Nginx configuration
RUN rm /etc/nginx/conf.d/*
ADD nginx.conf /etc/nginx/nginx.conf
ADD nginx-vhost.conf /etc/nginx/sites-enabled/app.conf

# PHP configuration
ADD php-env-vars.conf /etc/php7/php-env-vars.conf
ADD php-fpm.conf /etc/php7/php-fpm.conf
ADD php.ini /etc/php7/php.ini

# Supervisord configuration
ADD supervisord.conf /etc/supervisor/conf.d/supervisord.conf

CMD ["supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]

So, basically, biggest differences were that I needed to create additional nginx directory in /run because it was failing, and then alpine nginx does not come with sites-enabled directory because it is more or less debian thing. As well as php-fpm config seems to be a bit different than it is on Ubuntu, so I needed to add this custom thing as well. And Supervisor config also stays in different place by default, so needed to change that as well.
As well as, this is sh and ash shell thing, but mkdir -p /run/{nginx,php} does not work with these shells as we are used to do with bash

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant