From 3f5cdcc558643e880fd4a80c8411c26e3f22852d Mon Sep 17 00:00:00 2001 From: eko Date: Mon, 16 Mar 2026 06:41:29 +0700 Subject: [PATCH] fix pipeline --- .gitea/workflows/pipeline.yml | 53 ++++++++++------------------------- Dockerfile | 21 +++++++++----- 2 files changed, 29 insertions(+), 45 deletions(-) diff --git a/.gitea/workflows/pipeline.yml b/.gitea/workflows/pipeline.yml index 658a44b..7b56fc9 100644 --- a/.gitea/workflows/pipeline.yml +++ b/.gitea/workflows/pipeline.yml @@ -1,8 +1,10 @@ -name: Build, Push and Run Container -on: [push] +name: Build, Push and Deploy +on: + push: + branches: [ main, master ] jobs: - build-and-run: + build-and-deploy: runs-on: ubuntu-latest steps: - name: Checkout code @@ -10,20 +12,7 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - with: - config-inline: | - [registry."kode.sadateknologi.site"] - http = false - insecure = false - # Login to Docker Hub for pulling base images (optional) - - name: Login to Docker Hub - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - - # Login to Gitea Registry - name: Login to Gitea Registry uses: docker/login-action@v3 with: @@ -31,37 +20,25 @@ jobs: username: ${{ gitea.repository_owner }} password: ${{ secrets.REGISTRY_TOKEN }} - # Build and push image to Gitea Registry - - name: Build and push + # Build with the FIXED Dockerfile that includes composer install + - name: Build and push fixed image uses: docker/build-push-action@v5 with: context: . push: true tags: | - kode.sadateknologi.site/${{ gitea.repository_owner }}/kulakpos_web:latest - kode.sadateknologi.site/${{ gitea.repository_owner }}/kulakpos_web:${{ gitea.sha }} + kode.sadateknologi.site/yanto/kulakpos_web:latest + kode.sadateknologi.site/yanto/kulakpos_web:${{ gitea.sha }} - # Stop and remove existing container (if any) - - name: Stop existing container + # Deploy the fixed image + - name: Deploy run: | docker stop kulakpos_web || true docker rm kulakpos_web || true - continue-on-error: true - - # Run the new container - - name: Run container - run: | + docker pull kode.sadateknologi.site/yanto/kulakpos_web:latest docker run -d \ --name kulakpos_web \ - --restart unless-stopped \ -p 8000:8000 \ - -e PORT=8000 \ - -e NODE_ENV=production \ - kode.sadateknologi.site/${{ gitea.repository_owner }}/kulakpos_web:latest - - # Verify container is running - - name: Verify container - run: | - sleep 5 - docker ps | grep kulakpos_web - curl -f http://localhost:8000/health || echo "Health check endpoint not configured" \ No newline at end of file + -e MODE=dev \ + -e APP_ENV=local \ + kode.sadateknologi.site/yanto/kulakpos_web:latest \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 38b30d0..4378ddf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,11 @@ FROM php:8.2-fpm-alpine -# Install PostgreSQL extensions +# Install dependencies RUN apk add --no-cache \ libzip-dev \ postgresql-dev \ + git \ + curl \ && docker-php-ext-install -j$(nproc) \ pdo_pgsql \ pgsql \ @@ -15,12 +17,21 @@ RUN apk add --no-cache \ opcache \ zip +# Install Composer +COPY --from=composer:latest /usr/bin/composer /usr/bin/composer + WORKDIR /var/www/html +# Copy composer files first (for better caching) +COPY composer.json composer.lock ./ + +# Install dependencies +RUN composer install --no-dev --no-interaction --no-progress --optimize-autoloader + # Copy application files COPY --chown=www-data:www-data . . -# Create all necessary directories with proper permissions +# Create necessary directories RUN mkdir -p storage/framework/{cache,sessions,views} \ && mkdir -p storage/logs \ && mkdir -p bootstrap/cache \ @@ -29,7 +40,7 @@ RUN mkdir -p storage/framework/{cache,sessions,views} \ && chmod 777 storage/framework/sessions \ && chmod 777 storage/logs -# Create startup script to handle different modes +# Create startup script RUN echo '#!/bin/sh' > /start.sh && \ echo 'if [ "$MODE" = "dev" ]; then' >> /start.sh && \ echo ' echo "Starting in DEV mode with PHP built-in server on port 8000..."' >> /start.sh && \ @@ -40,10 +51,6 @@ RUN echo '#!/bin/sh' > /start.sh && \ echo 'fi' >> /start.sh && \ chmod +x /start.sh -# Verify permissions (for debugging) -RUN ls -la storage/framework/ - EXPOSE 8000 9000 -# Use the startup script CMD ["/start.sh"] \ No newline at end of file