From a0e4d91068c0d4348b294f13280107b498f2dcdc Mon Sep 17 00:00:00 2001 From: Triono Putra Date: Wed, 28 May 2025 22:39:09 +0700 Subject: [PATCH] Update --- .drone.yml | 2 +- Dockerfile | 61 ++++++++++++++++++++++++++++------------------ docker-compose.yml | 48 ++++++++++++++++++++++++------------ 3 files changed, 70 insertions(+), 41 deletions(-) diff --git a/.drone.yml b/.drone.yml index 926604b..ece06a9 100644 --- a/.drone.yml +++ b/.drone.yml @@ -22,7 +22,7 @@ steps: - apk add --no-cache curl bash - echo "$REGISTRY_PASSWORD" | docker login -u "$REGISTRY_USERNAME" --password-stdin registry.git.appstaging.my.id - docker buildx create --use --name mybuilder || true - - docker buildx build --platform linux/arm64 linux/amd64 -t registry.git.appstaging.my.id/reihanrere/sistem-akademik/sistem-akademik-dev -f Dockerfile . --push + - docker buildx build --platform linux/arm64 -t registry.git.appstaging.my.id/reihanrere/sistem-akademik/sistem-akademik-dev -f Dockerfile . --push - name: deploy-image-dev image: debian:latest diff --git a/Dockerfile b/Dockerfile index dbc9259..0433224 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,36 +1,49 @@ -# Define the base image -FROM teguh02/laravel-filament:latest +FROM php:8.3-fpm -# Set user to root -USER root +# 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 -# Change the working directory +# Install Composer +COPY --from=composer:2 /usr/bin/composer /usr/bin/composer + +# Set working directory WORKDIR /var/www -# Remove the all files in the /var/www/html directory -RUN rm -rf /var/www/html/* +# Copy source +COPY . . +COPY .env.example .env -# Copy laravel public directory to the /var/www/html directory -COPY ./public /var/www/html +# Set www-data user permission before running composer/install artisan +RUN chown -R www-data:www-data /var/www -# Copy the project files to the /var/www directory -COPY . /var/www +USER www-data -# Install the project dependencies -RUN composer install -RUN npm install +# Install dependencies & generate app key as www-data user +RUN composer install --no-interaction --prefer-dist --optimize-autoloader \ + && php artisan key:generate -# Build the vite -RUN npm run build +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 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 +RUN sed -i 's/error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT/error_reporting = E_ALL/g' /etc/php/8.3/fpm/php.ini + +EXPOSE 9000 +CMD ["php-fpm"] diff --git a/docker-compose.yml b/docker-compose.yml index 26ea3cb..e53a3f4 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,24 +1,40 @@ +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: - - 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 + - 8282:80 + depends_on: + - sistem-akademik-dev + restart: always labels: - "traefik.enable=true" - "traefik.http.routers.web-http.entrypoints=web" @@ -29,7 +45,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: