Update Dockerfile
Browse files- Dockerfile +1 -48
Dockerfile
CHANGED
|
@@ -1,20 +1,15 @@
|
|
| 1 |
-
# File: Dockerfile
|
| 2 |
FROM nextcloud:apache
|
| 3 |
|
| 4 |
-
# Hugging Face will route HTTPS to this container port
|
| 5 |
ENV APACHE_PORT=7860
|
| 6 |
|
| 7 |
RUN echo "ServerName localhost" >> /etc/apache2/apache2.conf \
|
| 8 |
&& sed -i "s/Listen 80/Listen ${APACHE_PORT}/" /etc/apache2/ports.conf \
|
| 9 |
&& sed -i "s/:80/:${APACHE_PORT}/" /etc/apache2/sites-available/000-default.conf
|
| 10 |
|
| 11 |
-
# Install MariaDB server inside the same container
|
| 12 |
RUN apt-get update \
|
| 13 |
&& apt-get install -y --no-install-recommends mariadb-server mariadb-client \
|
| 14 |
&& rm -rf /var/lib/apt/lists/*
|
| 15 |
|
| 16 |
-
# Configure MariaDB to listen only locally
|
| 17 |
-
# Note: a trailing space after "\" breaks Docker line continuations
|
| 18 |
RUN { \
|
| 19 |
echo "[mysqld]"; \
|
| 20 |
echo "bind-address=127.0.0.1"; \
|
|
@@ -24,52 +19,10 @@ RUN { \
|
|
| 24 |
echo "innodb_file_per_table=1"; \
|
| 25 |
} > /etc/mysql/mariadb.conf.d/99-hf-space.cnf
|
| 26 |
|
| 27 |
-
# Startup script that launches MariaDB and then Nextcloud
|
| 28 |
COPY start.sh /start.sh
|
| 29 |
-
RUN chmod +x /start.sh
|
| 30 |
|
| 31 |
EXPOSE 7860
|
| 32 |
|
| 33 |
ENTRYPOINT ["/start.sh"]
|
| 34 |
CMD ["apache2-foreground"]
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
# File: start.sh
|
| 38 |
-
#!/usr/bin/env bash
|
| 39 |
-
set -euo pipefail
|
| 40 |
-
|
| 41 |
-
# Required variables (set these in Hugging Face Space Variables or Secrets)
|
| 42 |
-
: "${MYSQL_DATABASE:?Set MYSQL_DATABASE}"
|
| 43 |
-
: "${MYSQL_USER:?Set MYSQL_USER}"
|
| 44 |
-
: "${MYSQL_PASSWORD:?Set MYSQL_PASSWORD}"
|
| 45 |
-
|
| 46 |
-
# Ensure runtime directories exist
|
| 47 |
-
mkdir -p /run/mysqld
|
| 48 |
-
chown -R mysql:mysql /run/mysqld
|
| 49 |
-
|
| 50 |
-
# Initialize MariaDB on first start
|
| 51 |
-
if [ ! -d /var/lib/mysql/mysql ]; then
|
| 52 |
-
mariadb-install-db --user=mysql --datadir=/var/lib/mysql > /dev/null
|
| 53 |
-
fi
|
| 54 |
-
|
| 55 |
-
# Start MariaDB in the background
|
| 56 |
-
mysqld_safe --datadir=/var/lib/mysql --bind-address=127.0.0.1 &
|
| 57 |
-
|
| 58 |
-
# Wait for MariaDB
|
| 59 |
-
until mariadb-admin ping --silent > /dev/null 2>&1; do
|
| 60 |
-
sleep 1
|
| 61 |
-
done
|
| 62 |
-
|
| 63 |
-
# Create DB and user (idempotent)
|
| 64 |
-
mariadb -uroot <<SQL
|
| 65 |
-
CREATE DATABASE IF NOT EXISTS \`${MYSQL_DATABASE}\` CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
|
| 66 |
-
CREATE USER IF NOT EXISTS '${MYSQL_USER}'@'localhost' IDENTIFIED BY '${MYSQL_PASSWORD}';
|
| 67 |
-
GRANT ALL PRIVILEGES ON \`${MYSQL_DATABASE}\`.* TO '${MYSQL_USER}'@'localhost';
|
| 68 |
-
FLUSH PRIVILEGES;
|
| 69 |
-
SQL
|
| 70 |
-
|
| 71 |
-
# Tell the official Nextcloud entrypoint how to reach MariaDB
|
| 72 |
-
export MYSQL_HOST=127.0.0.1
|
| 73 |
-
|
| 74 |
-
# Hand off to the official Nextcloud entrypoint
|
| 75 |
-
exec /entrypoint.sh "$@"
|
|
|
|
|
|
|
| 1 |
FROM nextcloud:apache
|
| 2 |
|
|
|
|
| 3 |
ENV APACHE_PORT=7860
|
| 4 |
|
| 5 |
RUN echo "ServerName localhost" >> /etc/apache2/apache2.conf \
|
| 6 |
&& sed -i "s/Listen 80/Listen ${APACHE_PORT}/" /etc/apache2/ports.conf \
|
| 7 |
&& sed -i "s/:80/:${APACHE_PORT}/" /etc/apache2/sites-available/000-default.conf
|
| 8 |
|
|
|
|
| 9 |
RUN apt-get update \
|
| 10 |
&& apt-get install -y --no-install-recommends mariadb-server mariadb-client \
|
| 11 |
&& rm -rf /var/lib/apt/lists/*
|
| 12 |
|
|
|
|
|
|
|
| 13 |
RUN { \
|
| 14 |
echo "[mysqld]"; \
|
| 15 |
echo "bind-address=127.0.0.1"; \
|
|
|
|
| 19 |
echo "innodb_file_per_table=1"; \
|
| 20 |
} > /etc/mysql/mariadb.conf.d/99-hf-space.cnf
|
| 21 |
|
|
|
|
| 22 |
COPY start.sh /start.sh
|
| 23 |
+
RUN sed -i 's/\r$//' /start.sh && chmod +x /start.sh
|
| 24 |
|
| 25 |
EXPOSE 7860
|
| 26 |
|
| 27 |
ENTRYPOINT ["/start.sh"]
|
| 28 |
CMD ["apache2-foreground"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|