-
Notifications
You must be signed in to change notification settings - Fork 55
/
Copy pathDockerfile_dev
165 lines (130 loc) · 4.44 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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
FROM php:8.4.2-fpm
# Let's use bash as a default shell with login each time
SHELL ["/bin/bash", "--login", "-c"]
# Decrale used arguments from `compose.yaml` file
ARG HOST_UID
ARG HOST_GID
# Declare constants
ENV PATH "$PATH:/home/dev/.composer/vendor/bin:/app/vendor/bin"
ENV NVM_VERSION v0.40.1
ENV NODE_VERSION 23.5.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/Debian_12/ /' | \
tee /etc/apt/sources.list.d/shells:fish.list \
&& curl -fsSL https://download.opensuse.org/repositories/shells:fish/Debian_12/Release.key | \
gpg --dearmor | \
tee /etc/apt/trusted.gpg.d/shells_fish.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:2.7.8 /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
# Install security updates
RUN apt-get update \
&& apt-get install -y \
debsecan \
&& apt-get install --no-install-recommends -y \
$(debsecan --suite bookworm --format packages --only-fixed) \
&& rm -rf /var/lib/apt/lists/*
# Copy the Composer PHAR from the Composer image into the PHP image
COPY --from=composer:2.8.4 /usr/bin/composer /usr/bin/composer
# Enable Composer autocompletion
RUN composer completion bash > /etc/bash_completion.d/composer
# Copy development `php.ini` and PHP-FPM pool configuration to container
#
# Also note that these files mounted within `compose.yaml` file, so
# you don't need to build containers again if you change something just
# restart containers and you're good
COPY ./docker/php/php-dev.ini /usr/local/etc/php/php.ini
COPY ./docker/php/www-dev.conf /usr/local/etc/php-fpm.d/www.conf
RUN chmod -R o+s+w /usr/local/etc/php
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 \
&& echo 'dev ALL=(ALL) ALL' >> /etc/sudoers
RUN mkdir -p /home/dev/.config/fish/completions \
&& mkdir -p /home/dev/.config/fish/functions \
&& mkdir -p /home/dev/.local/share \
&& mkdir -p /home/dev/.npm \
&& mkdir -p /home/dev/.nvm \
&& chmod 777 -R /home/dev
# Define used work directory
WORKDIR /app
# Add everything inside docker image
COPY --chown=dev:dev . .
# 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
USER dev
RUN pip3 install thefuck --user --break-system-packages
# 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
USER root
RUN chmod 777 -R /home/dev
USER dev
# 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
COPY ./docker/fish /home/dev/.config/fish/
USER root
RUN chmod 777 -R /home/dev /tmp \
&& rm -rf /tmp/fish.node \
&& chgrp -hR dev /home/dev
USER dev
EXPOSE 9000
ENTRYPOINT ["/app/docker-entrypoint-dev.sh"]