Skip to content

Commit a0bb64c

Browse files
committed
reorganize to better use root vs www-data, etc.
1 parent d492d5a commit a0bb64c

File tree

1 file changed

+15
-18
lines changed

1 file changed

+15
-18
lines changed

Dockerfile

+15-18
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# https://hub.docker.com/_/debian
44
FROM debian:bookworm-slim
55

6+
67
# Configure apt not to prompt during docker build
78
ARG DEBIAN_FRONTEND=noninteractive
89

@@ -12,7 +13,7 @@ RUN apt-config dump \
1213
| sed -e's/1/0/' \
1314
| tee /etc/apt/apt.conf.d/99no-recommends-no-suggests
1415

15-
# Resynchronize the package
16+
# Resynchronize the package index files from their sources
1617
RUN apt-get update
1718

1819
# Install packages
@@ -44,21 +45,30 @@ RUN rm -rf /var/lib/apt/lists/*
4445
RUN adduser www-data sudo
4546
COPY config/www-data_startupservice /etc/sudoers.d/www-data_startupservice
4647

48+
# Initialize and start Apache service
49+
COPY config/startupservice.sh /startupservice.sh
50+
RUN chmod +x /startupservice.sh
51+
CMD ["sudo", "/startupservice.sh"]
52+
53+
54+
# Expose ports for Apache
55+
EXPOSE 80
56+
4757

4858
# Enable Apache modules
4959
RUN a2enmod php8.2
5060
RUN a2enmod rewrite
5161

5262

53-
# create an index directory
63+
# create an index directory and set permissions
5464
RUN mkdir -p /var/www/index
65+
RUN chown -R www-data:www-data /var/www/index
66+
5567

5668
# Install Composer
5769
RUN curl -sS https://getcomposer.org/installer \
5870
| php -- --install-dir=/usr/local/bin --filename=composer
5971

60-
# set permissions
61-
RUN chown -R www-data:www-data /var/www/index
6272

6373
# Install WordPress CLI
6474
RUN curl -L \
@@ -67,21 +77,8 @@ RUN curl -L \
6777
&& chmod +x wp-cli.phar \
6878
&& mv wp-cli.phar /usr/local/bin/wp
6979

80+
7081
# Set up WordPress
7182
USER www-data
7283
WORKDIR /var/www/index
7384
RUN wp core download
74-
75-
# Switch to root
76-
USER root
77-
78-
# Initialize and start Apache service
79-
COPY config/startupservice.sh /startupservice.sh
80-
RUN chmod +x /startupservice.sh
81-
82-
# Expose ports for Apache and MariaDB
83-
EXPOSE 80
84-
85-
CMD ["sudo", "/startupservice.sh"]
86-
87-
USER www-data

0 commit comments

Comments
 (0)