-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
40 lines (31 loc) · 1.1 KB
/
Dockerfile
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
FROM php:8.3
# Set working directory
WORKDIR /app
# Install dependencies and PHP extensions
RUN apt update \
# install, accepting prompts and avoiding unnecessary packages
&& apt install -y --no-install-recommends \
libzip-dev \
&& docker-php-ext-install sockets zip pdo pdo_mysql \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Install Composer
COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer
# Copy application source code (.dockerignore masks out all the unneeded files from the root directory)
COPY ./ ./
# Copy entrypoint script into /app and set permissions
COPY ./entrypoint.sh /app/entrypoint.sh
RUN chmod +x /app/entrypoint.sh
# Create non-root user and set permissions
RUN useradd -ms /bin/bash appuser \
&& mkdir /app/vendor \
&& touch /app/heartbeat.log \
&& chmod 777 /app/heartbeat.log \
&& chown -R appuser:appuser /app
# Switch to non-root user
USER appuser
# Install Composer dependencies
RUN composer install --no-dev --optimize-autoloader \
&& composer clear-cache
# Set entrypoint script
ENTRYPOINT ["/app/entrypoint.sh"]