Update Dockerfile
Browse files- Dockerfile +20 -9
Dockerfile
CHANGED
|
@@ -10,17 +10,28 @@ RUN apt-get update && \
|
|
| 10 |
&& apt-get clean \
|
| 11 |
&& rm -rf /var/lib/apt/lists/*
|
| 12 |
|
| 13 |
-
#
|
| 14 |
-
RUN
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
# Create necessary directories and set permissions for Nginx
|
| 17 |
RUN mkdir -p /var/lib/nginx/body /var/lib/nginx/proxy /var/log/nginx /run/nginx && \
|
| 18 |
-
|
| 19 |
-
chmod 777 /var/lib/nginx /var/log/nginx /run/nginx
|
| 20 |
|
| 21 |
# Create log files with correct permissions
|
| 22 |
RUN touch /var/log/nginx/access.log /var/log/nginx/error.log && \
|
| 23 |
-
chown www-data:www-data /var/log/nginx/access.log /var/log/nginx/error.log && \
|
| 24 |
chmod 777 /var/log/nginx/access.log /var/log/nginx/error.log
|
| 25 |
|
| 26 |
# Add custom Nginx configuration
|
|
@@ -40,11 +51,11 @@ RUN echo 'events {' > /etc/nginx/nginx.conf && \
|
|
| 40 |
echo ' }' >> /etc/nginx/nginx.conf && \
|
| 41 |
echo '}' >> /etc/nginx/nginx.conf
|
| 42 |
|
|
|
|
|
|
|
|
|
|
| 43 |
# Expose ports
|
| 44 |
EXPOSE 8080 3306
|
| 45 |
|
| 46 |
-
# Run Nginx as root
|
| 47 |
-
USER root
|
| 48 |
-
|
| 49 |
# Start MariaDB and Nginx services
|
| 50 |
-
CMD ["sh", "-c", "mysqld_safe & nginx -g 'daemon off;'"]
|
|
|
|
| 10 |
&& apt-get clean \
|
| 11 |
&& rm -rf /var/lib/apt/lists/*
|
| 12 |
|
| 13 |
+
# Create a new user with ID 1000
|
| 14 |
+
RUN useradd -m -u 1000 user
|
| 15 |
+
|
| 16 |
+
# Switch to the "user" user
|
| 17 |
+
USER user
|
| 18 |
+
|
| 19 |
+
# Set home to the user's home directory and configure environment variables
|
| 20 |
+
ENV HOME=/home/user \
|
| 21 |
+
PATH=/home/user/.local/bin:$PATH
|
| 22 |
+
|
| 23 |
+
# Set the working directory to the user's home directory
|
| 24 |
+
WORKDIR $HOME/app
|
| 25 |
+
|
| 26 |
+
# Switch to root to perform system-level configurations
|
| 27 |
+
USER root
|
| 28 |
|
| 29 |
# Create necessary directories and set permissions for Nginx
|
| 30 |
RUN mkdir -p /var/lib/nginx/body /var/lib/nginx/proxy /var/log/nginx /run/nginx && \
|
| 31 |
+
chmod -R 777 /var/lib/nginx /var/log/nginx /run/nginx
|
|
|
|
| 32 |
|
| 33 |
# Create log files with correct permissions
|
| 34 |
RUN touch /var/log/nginx/access.log /var/log/nginx/error.log && \
|
|
|
|
| 35 |
chmod 777 /var/log/nginx/access.log /var/log/nginx/error.log
|
| 36 |
|
| 37 |
# Add custom Nginx configuration
|
|
|
|
| 51 |
echo ' }' >> /etc/nginx/nginx.conf && \
|
| 52 |
echo '}' >> /etc/nginx/nginx.conf
|
| 53 |
|
| 54 |
+
# Revert to user for application-specific operations
|
| 55 |
+
USER user
|
| 56 |
+
|
| 57 |
# Expose ports
|
| 58 |
EXPOSE 8080 3306
|
| 59 |
|
|
|
|
|
|
|
|
|
|
| 60 |
# Start MariaDB and Nginx services
|
| 61 |
+
CMD ["sh", "-c", "sudo mysqld_safe & nginx -g 'daemon off;'"]
|