forked from tarlepp/symfony-flex-backend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile_dev
146 lines (116 loc) · 4.12 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
FROM php:8.2.0-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"
ENV NVM_VERSION v0.39.2
ENV NODE_VERSION 19.2.0
# Update package list and install necessary libraries
RUN apt-get update \
&& apt-get install -y \
bash-completion \
fish \
g++ \
git \
gnupg \
iproute2 \
jq \
libicu-dev \
libxml2-dev \
libzip-dev \
locales \
nano \
python3-dev \
python3-pip \
python3-setuptools \
sudo \
unzip \
vim \
wget \
zlib1g-dev \
&& rm -rf /var/lib/apt/lists/*
RUN echo 'deb http://download.opensuse.org/repositories/shells:/fish:/release:/3/Debian_11/ /' | \
tee /etc/apt/sources.list.d/shells:fish:release:3.list \
&& curl -fsSL https://download.opensuse.org/repositories/shells:fish:release:3/Debian_11/Release.key | \
gpg --dearmor | \
tee /etc/apt/trusted.gpg.d/shells_fish_release_3.gpg > /dev/null \
&& apt-get update \
&& apt-get install -y \
fish \
&& rm -rf /var/lib/apt/lists
# Set the locale
RUN sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen \
&& locale-gen
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8
# Copy the install-php-extensions (Easily install PHP extension in official PHP Docker containers)
COPY --from=mlocati/php-extension-installer:1.5.51 /usr/bin/install-php-extensions /usr/local/bin/
# Enable all necessary PHP packages
RUN install-php-extensions \
apcu \
bcmath \
igbinary \
intl \
opcache \
pdo_mysql \
xdebug \
zip
# Copy the Composer PHAR from the Composer image into the PHP image
COPY --from=composer:2.4.4 /usr/bin/composer /usr/bin/composer
# Enable Composer autocompletion
RUN composer completion bash > /etc/bash_completion.d/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
# Enable PHP-FPM status page
RUN echo 'pm.status_path = /status' >> /usr/local/etc/php-fpm.d/www.conf
RUN curl -s https://api.github.com/repos/fabpot/local-php-security-checker/releases/latest | \
grep -E "browser_download_url(.+)linux_amd64" | \
cut -d : -f 2,3 | \
tr -d \" | \
xargs -I{} wget -O local-php-security-checker {} \
&& mv local-php-security-checker /usr/bin/local-php-security-checker \
&& chmod +x /usr/bin/local-php-security-checker
RUN groupadd --gid ${HOST_GID} dev \
&& useradd \
-p $(perl \
-e 'print crypt($ARGV[0], "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
RUN pip3 install thefuck --user
# Add necessary stuff to bash autocomplete
ENV PATH "$PATH:/home/dev/.local/bin"
RUN echo 'eval "$(thefuck --alias)"' >> /home/dev/.bashrc
# 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 'alias console="/app/bin/console"' >> /home/dev/.bashrc
RUN mkdir -p /home/dev/.config/fish/completions \
&& mkdir -p /home/dev/.config/fish/functions
COPY ./docker/fish /home/dev/.config/fish/
EXPOSE 9000
ENTRYPOINT ["/app/docker-entrypoint-dev.sh"]