diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..49a6388d --- /dev/null +++ b/.dockerignore @@ -0,0 +1,6 @@ +database +node_modules +www/cache +www/dist +userdata +!userdata/wiki \ No newline at end of file diff --git a/.gitignore b/.gitignore index 23051876..00dc3a55 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,5 @@ userdata www/cache/ node_modules/ www/themes/new/css/custom.css +docker-compose.override.yml +.idea \ No newline at end of file diff --git a/docker-compose.override.example.yml b/docker-compose.override.example.yml new file mode 100644 index 00000000..f570b8e4 --- /dev/null +++ b/docker-compose.override.example.yml @@ -0,0 +1,8 @@ +# This file can be used to override defaults from the docker-compose.yml file +# if it is copied/renamed to docker-compose.override.yml + +version: '3.9' +services: + vite: + # Set this to your local uid:gid to run the frontend build as your user and keep the working directory clean + user: 1000:1000 \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..02bacd4f --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,62 @@ +version: '3.9' +services: + vite: + build: + context: . + dockerfile: docker/Dockerfile + target: frontend + image: openxe_frontend + entrypoint: npm run dev + volumes: + - .:/app + ports: + - "5173:5173" + app_init: + image: openxe:test + volumes: + - .:/var/www/html + working_dir: /var/www/html/upgrade + entrypoint: php data/upgrade.php -db -do + depends_on: + mysql: + condition: service_healthy + app: + build: + context: . + dockerfile: docker/Dockerfile + image: openxe:test + volumes: + - .:/var/www/html + ports: + - "8081:80" + depends_on: + app_init: + condition: service_completed_successfully + mysql: + condition: service_healthy + mysql: + image: mariadb:10.11 + environment: + MYSQL_ROOT_PASSWORD: "rootpw" + MYSQL_USER: "openxe" + MYSQL_PASSWORD: "openxe" + MYSQL_DATABASE: "openxe" + MARIADB_AUTO_UPGRADE: "1" + volumes: + - mysqldata:/var/lib/mysql + ports: + - "3306:3306" + healthcheck: + interval: 5s + retries: 3 + test: + [ + "CMD", + "healthcheck.sh", + "--connect", + "--innodb_initialized" + ] + timeout: 30s + +volumes: + mysqldata: {} \ No newline at end of file diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 00000000..1fe08d88 --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,27 @@ +ARG PHP_EXT="gd ldap imap mysqli soap zip" +ARG DEB_PKG="libc-client2007e libaom3 libavif15 libdav1d6 libfreetype6 libjpeg62-turbo libldap-common libpng16-16 libwebp7 libxpm4 libzip4" +ARG DEB_PKG_TMP="cmake gnutls-dev libaom-dev libavif-dev libbz2-dev libc-client-dev libdav1d-dev libfreetype6-dev libjpeg62-turbo-dev libkrb5-dev libldap2-dev libpng-dev libssl-dev libwebp-dev libxml2-dev libxpm-dev libzip-dev zlib1g-dev" + +FROM node:20 as frontend +WORKDIR /app +COPY package.json package-lock.json vite.config.js /app/ +RUN npm install +COPY classes /app/classes +COPY resources /app/resources +COPY www /app/www +RUN npm run build + +#FROM php:8.1-fpm as fpm_server +FROM php:8.1-apache as web_server +ARG PHP_EXT +ARG DEB_PKG +ARG DEB_PKG_TMP + +WORKDIR /app +RUN apt-get update && apt-get install -y ${DEB_PKG} ${DEB_PKG_TMP} && \ + docker-php-ext-configure imap --with-kerberos --with-imap-ssl && \ + docker-php-ext-install ${PHP_EXT} && \ + apt-get remove --purge -y ${DEB_PKG_TMP} + +COPY --chown=www-data:www-data . /var/www/html +COPY --chown=www-data:www-data --from=frontend /app/www/dist /var/www/html/www/dist \ No newline at end of file