diff --git a/Docker/DockerfileLaravelProd b/Docker/DockerfileLaravelProd index 0a3a64680..961a3e8ee 100644 --- a/Docker/DockerfileLaravelProd +++ b/Docker/DockerfileLaravelProd @@ -1,4 +1,7 @@ -FROM php:8-fpm +FROM php:8.2-fpm + +WORKDIR /app +COPY ./Website/htdocs/mpmanager /app RUN apt-get update && \ apt-get install -y \ @@ -13,26 +16,43 @@ RUN apt-get update && \ supervisor \ libzip-dev \ vim \ - git + git \ + zsh \ + unzip # Add unzip for Composer + +# install ohmyzsh +RUN chsh -s $(which zsh) +RUN sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" +# add php artisan alias +RUN echo 'alias "cmd=php artisan"' >> ~/.zshrc # remove apt lists RUN rm -rf /var/lib/apt/lists/* -# install php extentions +# install php extensions RUN docker-php-ext-install gd mysqli zip pdo pdo_mysql soap ftp opcache bcmath pcntl RUN docker-php-ext-configure gd --with-freetype --with-jpeg\ && docker-php-ext-configure pcntl --enable-pcntl +# Download composer.phar +RUN curl -sS https://getcomposer.org/composer.phar -o /usr/local/bin/composer.phar + RUN touch /usr/local/etc/php/conf.d/xdebug.ini; \ echo xdebug.remote_enable=1 >> /usr/local/etc/php/conf.d/xdebug.ini; \ echo xdebug.remote_autostart=0 >> /usr/local/etc/php/conf.d/xdebug.ini; \ - echo xdebug.remote_connephpct_back=1 >> /usr/local/etc/php/conf.d/xdebug.ini; \ + echo xdebug.remote_connect_back=1 >> /usr/local/etc/php/conf.d/xdebug.ini; \ echo xdebug.remote_port=9000 >> /usr/local/etc/php/conf.d/xdebug.ini; \ echo xdebug.remote_log=/tmp/php5-xdebug.log >> /usr/local/etc/php/conf.d/xdebug.ini; -EXPOSE 9000 -COPY ./owner-changer.sh /owner-changer.sh -RUN chmod +x /owner-changer.sh -ENTRYPOINT ["/owner-changer.sh"] -CMD ["www-data"] +# Run the composer install +RUN php /usr/local/bin/composer.phar install + +EXPOSE 80 + +COPY ./Docker/vhost.conf /etc/apache2/sites-available/000-default.conf + +RUN chown -R www-data:www-data /app +RUN chmod -R 775 /app/storage + +RUN a2enmod rewrite diff --git a/Docker/vhost.conf b/Docker/vhost.conf new file mode 100644 index 000000000..6f28058e2 --- /dev/null +++ b/Docker/vhost.conf @@ -0,0 +1,11 @@ + + DocumentRoot /app/public + + + AllowOverride all + Require all granted + + + ErrorLog ${APACHE_LOG_DIR}/error.log + CustomLog ${APACHE_LOG_DIR}/access.log combined + \ No newline at end of file diff --git a/Website/ui/Dockerfile b/Website/ui/Dockerfile index c34d1d051..352661714 100644 --- a/Website/ui/Dockerfile +++ b/Website/ui/Dockerfile @@ -1,24 +1,23 @@ FROM node:18.20.4 + +# install simple http server for serving static content +RUN npm install -g http-server + +# make the 'app' folder the current working directory WORKDIR /app -COPY package.json /app/ +# copy both 'package.json' and 'package-lock.json' (if available) +COPY package*.json ./ +# install project dependencies RUN npm install -COPY . /app - -RUN mkdir -p dist +# copy project files and folders to the current working directory (i.e. 'app' folder) +COPY . . +# build app for production with minification RUN npm run build -COPY entrypoint-dev.sh /tmp/entrypoint-dev.sh - -RUN chmod +x /tmp/entrypoint-dev.sh - -RUN cp -a /app/. /app_backup - -ENTRYPOINT [ "/tmp/entrypoint-dev.sh"] - EXPOSE 8081 -CMD [ "tail", "-f", "/dev/null" ] +CMD [ "http-server", "dist", "-p", "8081" ] \ No newline at end of file diff --git a/docs/development/build-for-production.md b/docs/development/build-for-production.md new file mode 100644 index 000000000..1d7aeb7ed --- /dev/null +++ b/docs/development/build-for-production.md @@ -0,0 +1,23 @@ +--- +order: 6 +--- + +# Building docker image for production + +## Backend Prod + +From the root directory run + +```bash +docker build --platform linux/amd64 -t micropowermanager-laravel-prod -f Docker/DockerfileLaravelProd . +``` + +## Frontend Prod + +```bash +cd Website/ui +``` + +```bash +docker build --platform linux/amd64 -t micropowermanager-frontend-prod -f Dockerfile +```