fix pipeline
This commit is contained in:
@@ -1,8 +1,10 @@
|
|||||||
name: Build, Push and Run Container
|
name: Build, Push and Deploy
|
||||||
on: [push]
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ main, master ]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-and-run:
|
build-and-deploy:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
@@ -10,20 +12,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
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
|
- name: Login to Gitea Registry
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
@@ -31,37 +20,25 @@ jobs:
|
|||||||
username: ${{ gitea.repository_owner }}
|
username: ${{ gitea.repository_owner }}
|
||||||
password: ${{ secrets.REGISTRY_TOKEN }}
|
password: ${{ secrets.REGISTRY_TOKEN }}
|
||||||
|
|
||||||
# Build and push image to Gitea Registry
|
# Build with the FIXED Dockerfile that includes composer install
|
||||||
- name: Build and push
|
- name: Build and push fixed image
|
||||||
uses: docker/build-push-action@v5
|
uses: docker/build-push-action@v5
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
push: true
|
push: true
|
||||||
tags: |
|
tags: |
|
||||||
kode.sadateknologi.site/${{ gitea.repository_owner }}/kulakpos_web:latest
|
kode.sadateknologi.site/yanto/kulakpos_web:latest
|
||||||
kode.sadateknologi.site/${{ gitea.repository_owner }}/kulakpos_web:${{ gitea.sha }}
|
kode.sadateknologi.site/yanto/kulakpos_web:${{ gitea.sha }}
|
||||||
|
|
||||||
# Stop and remove existing container (if any)
|
# Deploy the fixed image
|
||||||
- name: Stop existing container
|
- name: Deploy
|
||||||
run: |
|
run: |
|
||||||
docker stop kulakpos_web || true
|
docker stop kulakpos_web || true
|
||||||
docker rm kulakpos_web || true
|
docker rm kulakpos_web || true
|
||||||
continue-on-error: true
|
docker pull kode.sadateknologi.site/yanto/kulakpos_web:latest
|
||||||
|
|
||||||
# Run the new container
|
|
||||||
- name: Run container
|
|
||||||
run: |
|
|
||||||
docker run -d \
|
docker run -d \
|
||||||
--name kulakpos_web \
|
--name kulakpos_web \
|
||||||
--restart unless-stopped \
|
|
||||||
-p 8000:8000 \
|
-p 8000:8000 \
|
||||||
-e PORT=8000 \
|
-e MODE=dev \
|
||||||
-e NODE_ENV=production \
|
-e APP_ENV=local \
|
||||||
kode.sadateknologi.site/${{ gitea.repository_owner }}/kulakpos_web:latest
|
kode.sadateknologi.site/yanto/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"
|
|
||||||
21
Dockerfile
21
Dockerfile
@@ -1,9 +1,11 @@
|
|||||||
FROM php:8.2-fpm-alpine
|
FROM php:8.2-fpm-alpine
|
||||||
|
|
||||||
# Install PostgreSQL extensions
|
# Install dependencies
|
||||||
RUN apk add --no-cache \
|
RUN apk add --no-cache \
|
||||||
libzip-dev \
|
libzip-dev \
|
||||||
postgresql-dev \
|
postgresql-dev \
|
||||||
|
git \
|
||||||
|
curl \
|
||||||
&& docker-php-ext-install -j$(nproc) \
|
&& docker-php-ext-install -j$(nproc) \
|
||||||
pdo_pgsql \
|
pdo_pgsql \
|
||||||
pgsql \
|
pgsql \
|
||||||
@@ -15,12 +17,21 @@ RUN apk add --no-cache \
|
|||||||
opcache \
|
opcache \
|
||||||
zip
|
zip
|
||||||
|
|
||||||
|
# Install Composer
|
||||||
|
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
|
||||||
|
|
||||||
WORKDIR /var/www/html
|
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 application files
|
||||||
COPY --chown=www-data:www-data . .
|
COPY --chown=www-data:www-data . .
|
||||||
|
|
||||||
# Create all necessary directories with proper permissions
|
# Create necessary directories
|
||||||
RUN mkdir -p storage/framework/{cache,sessions,views} \
|
RUN mkdir -p storage/framework/{cache,sessions,views} \
|
||||||
&& mkdir -p storage/logs \
|
&& mkdir -p storage/logs \
|
||||||
&& mkdir -p bootstrap/cache \
|
&& mkdir -p bootstrap/cache \
|
||||||
@@ -29,7 +40,7 @@ RUN mkdir -p storage/framework/{cache,sessions,views} \
|
|||||||
&& chmod 777 storage/framework/sessions \
|
&& chmod 777 storage/framework/sessions \
|
||||||
&& chmod 777 storage/logs
|
&& chmod 777 storage/logs
|
||||||
|
|
||||||
# Create startup script to handle different modes
|
# Create startup script
|
||||||
RUN echo '#!/bin/sh' > /start.sh && \
|
RUN echo '#!/bin/sh' > /start.sh && \
|
||||||
echo 'if [ "$MODE" = "dev" ]; then' >> /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 && \
|
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 && \
|
echo 'fi' >> /start.sh && \
|
||||||
chmod +x /start.sh
|
chmod +x /start.sh
|
||||||
|
|
||||||
# Verify permissions (for debugging)
|
|
||||||
RUN ls -la storage/framework/
|
|
||||||
|
|
||||||
EXPOSE 8000 9000
|
EXPOSE 8000 9000
|
||||||
|
|
||||||
# Use the startup script
|
|
||||||
CMD ["/start.sh"]
|
CMD ["/start.sh"]
|
||||||
Reference in New Issue
Block a user