Commit 2ca7e298 authored by Jacob Priddy's avatar Jacob Priddy 👌

fix dockerfiles for deployment

parent a6875696
Pipeline #13202 passed with stages
in 2 minutes and 15 seconds
......@@ -90,6 +90,14 @@ deploy application:
- elock
stage: deploy
script:
# Delete previous unneeded artifacts
- >
rm -rf src/backend/cov
src/backend/vendor
src/backend/tests
src/frontend
src/install-dev.sh
src/backend/node_modules
- docker-compose -f docker-compose.prod.yml build
- docker build -t $DOORCODE_IMAGE_NAME -f prod.Dockerfile .
- docker build -t $NGINX_IMAGE_NAME -f nginx.Dockerfile .
......
FROM node:15.4-alpine as frontend_assets
WORKDIR /app
COPY src/backend/public public
COPY src/backend/resources resources
COPY src/backend/package.json src/backend/package-lock.json src/backend/webpack.mix.js ./
RUN npm install && npm run prod
FROM nginx:1.19.5-alpine
WORKDIR /var/www
COPY src/ ${WORKDIR}
COPY simplesamlphp-1.19.0-rc1/ ${WORKDIR}../simplesamlphp
COPY simple-saml/ ${WORKDIR}../simplesamlphp
COPY nginx/conf.d/prod.conf:/etc/nginx/conf.d/prod.conf
COPY simplesamlphp-1.19.0-rc1/ ../simplesamlphp
COPY nginx/conf.d/prod.conf /etc/nginx/conf.d/prod.conf
COPY nginx/dhparam/ /run/dhparam
CMD ["/docker-entrypoint.sh"]
RUN rm -rf backend/cov backend/vendor backend/public \
../simplesamlphp/modules/exampleauth/enable \
backend/tests frontend backend/install-dev.sh install-dev.sh \
backend/node_modules
COPY --from=frontend_assets /app/public backend/public
......@@ -2,10 +2,11 @@ FROM node:15.4-alpine as frontend_assets
WORKDIR /app
COPY --chown=www:www src/backend .
COPY src/backend/public public
COPY src/backend/resources resources
COPY src/backend/package.json src/backend/package-lock.json src/backend/webpack.mix.js ./
RUN npm install && npm run prod
FROM php:8.0-fpm-alpine
ENV PROJECT_DIR /var/www
......@@ -33,24 +34,27 @@ RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local
# Add user for application and create source directories
RUN groupadd -g 1000 www && \
useradd -u 1000 -ms /bin/bash -g www www
useradd -u 1000 -ms /bin/sh -g www www
# Copy existing application directory permissions
COPY bin/docker-entrypoint.sh /
COPY --chown=www:www src/ ${WORKDIR}
COPY --chown=www:www simplesamlphp-1.19.0-rc1/ ${WORKDIR}../simplesamlphp
COPY --chown=www:www --from=frontend_assets /app/public ${WORKDIR}/backend/
COPY --chown=www:www simplesamlphp-1.19.0-rc1/ ../simplesamlphp
COPY php/prod.ini /usr/local/etc/php/conf.d/local.ini
RUN rm -rf backend/cov backend/vendor backend/public \
../simplesamlphp/modules/exampleauth/enable \
backend/tests frontend backend/install-dev.sh install-dev.sh \
backend/node_modules \
&& chmod 0755 /docker-entrypoint.sh
COPY --chown=www:www --from=frontend_assets /app/public backend/public
# Change current user to www
USER www
# exampleauth is not used for production
RUN rm -rf backend/cov backend/vendor ../simplesamlphp/modules/exampleauth/enable backend/tests frontend install-dev.sh \
&& cd backend \
&& composer.phar install --no-ansi --no-dev --no-interaction --no-plugins --no-progress --no-scripts --optimize-autoloader \
&& chmod 0755 /docker-entrypoint.sh \
&& php artisan apidoc:generate \
# Install application and prep it for production use
RUN cd backend \
&& composer install --no-ansi --no-cache --no-dev --no-interaction --no-plugins --no-progress --no-scripts --optimize-autoloader \
&& composer dump-autoload \
&& php artisan optimize \
&& php artisan config:cache \
&& php artisan route:cache \
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment