-
Notifications
You must be signed in to change notification settings - Fork 1
/
DockerfileTests
62 lines (52 loc) · 1.76 KB
/
DockerfileTests
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
ARG APP_USER_NAME=app
ARG APP_USER_UID=1000
ARG APP_USER_GID=1000
FROM php:8.2-cli
ENV DEBIAN_FRONTEND noninteractive
ENV COMPOSER_ALLOW_SUPERUSER 1
ENV COMPOSER_FLAGS="--prefer-dist --no-interaction"
ARG APP_USER_NAME
ARG APP_USER_UID
ARG APP_USER_GID
RUN apt-get update -q \
&& apt-get install -y --no-install-recommends \
apt-transport-https \
ca-certificates \
git \
gnupg2 \
libmcrypt-dev \
libpq-dev \
openssh-server \
software-properties-common \
sudo \
unzip \
libzip-dev \
wget \
iproute2 \
&& rm -rf /var/lib/apt/lists/*
# install composer
RUN docker-php-ext-install zip \
&& curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin/ --filename=composer
# install docker
RUN wget https://download.docker.com/linux/debian/gpg \
&& sudo apt-key add gpg \
&& echo "deb [arch=$(dpkg --print-architecture)] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | sudo tee -a /etc/apt/sources.list.d/docker.list \
&& apt-get update \
&& apt-cache policy docker-ce \
&& apt-get -y install docker-ce \
&& rm -rf /var/lib/apt/lists/*
# install xdebug
RUN yes | pecl install xdebug \
&& docker-php-ext-enable xdebug
COPY ./docker/php.ini /usr/local/etc/php/php.ini
WORKDIR /code/
# create app user
RUN groupadd -g $APP_USER_GID $APP_USER_NAME \
&& useradd -m -u $APP_USER_UID -g $APP_USER_GID $APP_USER_NAME \
&& usermod -a -G docker $APP_USER_NAME \
&& printf "%s ALL=(ALL:ALL) NOPASSWD: ALL" "$APP_USER_NAME" >> /etc/sudoers.d/$APP_USER_NAME
COPY composer.* ./
RUN composer install $COMPOSER_FLAGS --no-scripts --no-autoloader
COPY . .
RUN composer install $COMPOSER_FLAGS
USER $APP_USER_NAME