Download Dockerfile from stat-utas/test: direct link, hf CLI and curl.
- Browser
- Download file 2.34 kB
-
https://huggingface.co/spaces/stat-utas/test/resolve/main/Dockerfile
- Command line
-
hf download hf://spaces/stat-utas/test/Dockerfile
-
curl -L -o Dockerfile https://huggingface.co/spaces/stat-utas/test/resolve/main/Dockerfile
2.34 kB
| # Use the official Ubuntu image as a base | |
| FROM ubuntu:latest | |
| # Install necessary packages | |
| RUN apt-get update && \ | |
| apt-get install -y \ | |
| nginx \ | |
| mariadb-server \ | |
| mariadb-client \ | |
| && apt-get clean \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Create a new user with a unique user ID and group ID | |
| # Check if user/group exists before creating | |
| RUN if ! getent group 1000 >/dev/null; then groupadd -g 1000 user; fi && \ | |
| if ! id -u 1000 >/dev/null 2>&1; then useradd -m -u 1000 -g user user; fi | |
| # Switch to the "user" user | |
| USER user | |
| # Set home to the user's home directory and configure environment variables | |
| ENV HOME=/home/user \ | |
| PATH=/home/user/.local/bin:$PATH | |
| # Set the working directory to the user's home directory | |
| WORKDIR $HOME/app | |
| # Switch to root to perform system-level configurations | |
| USER root | |
| # Create necessary directories and set permissions for Nginx | |
| RUN mkdir -p /var/lib/nginx/body /var/lib/nginx/proxy /var/log/nginx /run/nginx && \ | |
| chmod -R 777 /var/lib/nginx /var/log/nginx /run/nginx | |
| # Create log files with correct permissions | |
| RUN touch /var/log/nginx/access.log /var/log/nginx/error.log && \ | |
| chmod 777 /var/log/nginx/access.log /var/log/nginx/error.log | |
| # Add custom Nginx configuration | |
| RUN echo 'events {' > /etc/nginx/nginx.conf && \ | |
| echo ' worker_connections 1024;' >> /etc/nginx/nginx.conf && \ | |
| echo '}' >> /etc/nginx/nginx.conf && \ | |
| echo 'http {' >> /etc/nginx/nginx.conf && \ | |
| echo ' access_log /var/log/nginx/access.log;' >> /etc/nginx/nginx.conf && \ | |
| echo ' error_log /var/log/nginx/error.log;' >> /etc/nginx/nginx.conf && \ | |
| echo ' server {' >> /etc/nginx/nginx.conf && \ | |
| echo ' listen 8080;' >> /etc/nginx/nginx.conf && \ | |
| echo ' server_name localhost;' >> /etc/nginx/nginx.conf && \ | |
| echo ' location / {' >> /etc/nginx/nginx.conf && \ | |
| echo ' root /var/www/html;' >> /etc/nginx/nginx.conf && \ | |
| echo ' index index.html;' >> /etc/nginx/nginx.conf && \ | |
| echo ' }' >> /etc/nginx/nginx.conf && \ | |
| echo ' }' >> /etc/nginx/nginx.conf && \ | |
| echo '}' >> /etc/nginx/nginx.conf | |
| # Revert to user for application-specific operations | |
| USER user | |
| # Expose ports | |
| EXPOSE 8080 3306 | |
| # Start MariaDB and Nginx services | |
| CMD ["sh", "-c", "sudo mysqld_safe & nginx -g 'daemon off;'"] | |