diff --git a/Dockerfile b/Dockerfile index 649c5d3..dbc9259 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,44 +1,36 @@ -FROM php:8.3-fpm - -# Install system dependencies & PHP extensions -RUN apt-get update && apt-get install -y \ - libzip-dev \ - unzip \ - git \ - libpq-dev \ - libicu-dev \ - zip \ - curl \ - && docker-php-ext-install \ - intl \ - zip \ - pdo_pgsql \ - bcmath - -# Install Composer -COPY --from=composer:2 /usr/bin/composer /usr/bin/composer - -# Set working directory -WORKDIR /var/www - -# Copy source -COPY . . -COPY .env.example .env - -# Set www-data user permission before running composer/install artisan -RUN chown -R www-data:www-data /var/www - -USER www-data - -# Install dependencies & generate app key as www-data user -RUN composer install --no-interaction --prefer-dist --optimize-autoloader \ - && php artisan key:generate +# Define the base image +FROM teguh02/laravel-filament:latest +# Set user to root USER root -# Set permissions again just in case -RUN chown -R www-data:www-data /var/www/storage /var/www/bootstrap/cache \ - && chmod -R 775 /var/www/storage /var/www/bootstrap/cache +# Change the working directory +WORKDIR /var/www -EXPOSE 9000 -CMD ["php-fpm"] +# Remove the all files in the /var/www/html directory +RUN rm -rf /var/www/html/* + +# Copy laravel public directory to the /var/www/html directory +COPY ./public /var/www/html + +# Copy the project files to the /var/www directory +COPY . /var/www + +# Install the project dependencies +RUN composer install +RUN npm install + +# Build the vite +RUN npm run build + +# Change the directory permission +RUN chmod -R 777 /var/www + +# If you want to change the timezone of the container to UTC +# RUN sed -i 's/;date.timezone =/date.timezone = UTC/g' /etc/php/8.3/fpm/php.ini +# RUN sed -i 's/;date.timezone =/date.timezone = UTC/g' /etc/php/8.3/cli/php.ini + +# If you want to display the error message +RUN sed -i 's/display_errors = Off/display_errors = On/g' /etc/php/8.3/fpm/php.ini +RUN sed -i 's/display_errors = Off/display_errors = On/g' /etc/php/8.3/cli/php.ini +RUN sed -i 's/error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT/error_reporting = E_ALL/g' /etc/php/8.3/fpm/php.ini diff --git a/docker-compose.yml b/docker-compose.yml index e53a3f4..26ea3cb 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,40 +1,24 @@ -version: "3" - services: sistem-akademik-dev: - build: . container_name: sistem-akademik-dev + build: + context: . + dockerfile: Dockerfile volumes: + - ./public:/var/www/html - .:/var/www - - ./storage:/var/www/storage - working_dir: /var/www - expose: - - 9000 - restart: always - environment: - APP_ENV: production - APP_DEBUG: false - APP_KEY: base64:Wz4daUZXYysRm1vUWBWTjQ5v0JFWBsQ2wPw2tHRALgY= - DB_CONNECTION: pgsql - DB_HOST: appstaging.my.id - DB_PORT: 5432 - DB_DATABASE: SISKA_2025 - DB_USERNAME: root - DB_PASSWORD: postroot123 - networks: - - traefik_default - - web: - image: nginx:alpine - container_name: sistem-akademik-dev-web - volumes: - - .:/var/www - - ./nginx:/etc/nginx/conf.d ports: - - 8282:80 - depends_on: - - sistem-akademik-dev - restart: always + - 7271:80 + restart: unless-stopped + extra_hosts: + - "host.docker.internal:host-gateway" + healthcheck: + test: ["CMD", "curl", "-f", "http://localhost/up"] + interval: 30s + timeout: 10s + retries: 5 + env_file: + - .env labels: - "traefik.enable=true" - "traefik.http.routers.web-http.entrypoints=web" @@ -45,7 +29,7 @@ services: - "traefik.http.routers.web.rule=Host(`siska.appstaging.my.id`)" - 'traefik.http.routers.web.tls=true' networks: - - traefik_default + - traefik_default networks: traefik_default: