forked from tarlepp/symfony-flex-backend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile_dev
86 lines (66 loc) · 2.86 KB
/
Dockerfile_dev
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
FROM php:7.4.12-fpm
# Let's use bash as a default shell with login each time
SHELL ["/bin/bash", "--login", "-c"]
# Decrale used arguments from `docker-compose.yml` file
ARG HOST_UID
ARG HOST_GID
# Declare constants
ENV PATH "$PATH:/home/dev/.composer/vendor/bin:/app/vendor/bin:/app/bin"
ENV NVM_VERSION v0.35.3
ENV NODE_VERSION 15
# Update package list and install necessary libraries
RUN apt-get update && apt-get install -y \
zlib1g-dev libzip-dev libxml2-dev libicu-dev g++ nano vim git unzip jq bash-completion iproute2 sudo \
&& rm -rf /var/lib/apt/lists/*
# Enable all necessary PHP packages
RUN docker-php-ext-install -j$(nproc) bcmath \
&& docker-php-ext-install pdo \
&& docker-php-ext-install pdo_mysql \
&& docker-php-ext-configure intl \
&& docker-php-ext-install intl \
&& docker-php-ext-install opcache \
&& docker-php-ext-install zip \
&& pecl install xdebug-2.9.8 \
&& docker-php-ext-enable xdebug
# Install APCu and APC backward compatibility
RUN pecl install apcu \
&& pecl install apcu_bc-1.0.5 \
&& docker-php-ext-enable apcu --ini-name 10-docker-php-ext-apcu.ini \
&& docker-php-ext-enable apc --ini-name 20-docker-php-ext-apc.ini
# Copy the Composer PHAR from the Composer image into the PHP image
COPY --from=composer:2.0.7 /usr/bin/composer /usr/bin/composer
# Copy development `php.ini` configuration to container
COPY ./docker/php/php-dev.ini /usr/local/etc/php/php.ini
# Define used work directory
WORKDIR /app
# Add everything inside docker image
COPY . .
# Ensure that all required files has execute rights
RUN chmod +x /app/bin/console \
&& chmod +x /app/docker-entrypoint-dev.sh \
&& chmod +x /usr/bin/composer
RUN chmod -R o+s+w /usr/local/etc/php
RUN groupadd --gid ${HOST_GID} dev \
&& useradd --password dev --uid ${HOST_UID} --gid ${HOST_GID} --shell /bin/bash --create-home dev \
&& usermod -a -G www-data,sudo dev \
&& chgrp -hR dev /app
USER dev
# Install following common tools;
# - bamarni/symfony-console-autocomplete, to get application commands and composer autocomplete working
# - ergebnis/composer-normalize, to "normalize" composer.json contents
RUN composer --no-cache global require \
bamarni/symfony-console-autocomplete \
ergebnis/composer-normalize
# Install Node Version Manager (nvm)
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/$NVM_VERSION/install.sh | bash
# Node setup
# 1) Install defined version of node and use it as default
# 2) Install `composer-version` helper tool globally
RUN source ~/.nvm/nvm.sh \
&& nvm install $NODE_VERSION \
&& npm install -g composer-version
# Add necessary stuff to bash autocomplete
RUN echo 'source /usr/share/bash-completion/bash_completion' >> /home/dev/.bashrc \
&& echo 'eval "$(symfony-autocomplete --shell bash)"' >> /home/dev/.bashrc
EXPOSE 9000
ENTRYPOINT ["/app/docker-entrypoint-dev.sh"]