This commit is contained in:
@@ -6,27 +6,27 @@ on:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
build-and-deploy:
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
# - name: Checkout code
|
||||
# uses: actions/checkout@v3
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
# - name: Set up Docker Buildx
|
||||
# uses: docker/setup-buildx-action@v2
|
||||
|
||||
- name: Log in to Gitea Registry
|
||||
run: |
|
||||
echo "${{ secrets.REGISTRY_PASSWORD }}" | docker login git.oskarmikael.com -u ${{ secrets.REGISTRY_USER }} --password-stdin
|
||||
# - name: Log in to Gitea Registry
|
||||
# run: |
|
||||
# echo "${{ secrets.REGISTRY_PASSWORD }}" | docker login git.oskarmikael.com -u ${{ secrets.REGISTRY_USER }} --password-stdin
|
||||
|
||||
- name: Build and Push Docker image
|
||||
run: |
|
||||
IMAGE=git.oskarmikael.com/oskarb/scheduler:latest
|
||||
docker buildx build \
|
||||
-f Dockerfile.prod \
|
||||
--platform linux/amd64 \
|
||||
-t $IMAGE \
|
||||
--push .
|
||||
# - name: Build and Push Docker image
|
||||
# run: |
|
||||
# IMAGE=git.oskarmikael.com/oskarb/scheduler:latest
|
||||
# docker buildx build \
|
||||
# -f Dockerfile.prod \
|
||||
# --platform linux/amd64 \
|
||||
# -t $IMAGE \
|
||||
# --push .
|
||||
|
||||
# - name: Run migrations
|
||||
# run: |
|
||||
@@ -54,6 +54,7 @@ jobs:
|
||||
script: |
|
||||
cd /var/www/scheduler
|
||||
git pull origin master
|
||||
/usr/lib/docker/cli-plugins/docker-compose -f docker-compose.prod.yml pull
|
||||
/usr/lib/docker/cli-plugins/docker-compose -f docker-compose.prod.yml up -d
|
||||
/usr/lib/docker/cli-plugins/docker-compose -f docker-compose.prod.yml run --rm app php artisan migrate --force
|
||||
npm install
|
||||
npm run build
|
||||
composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
|
||||
php artisan migrate --force
|
||||
|
||||
@@ -1,82 +0,0 @@
|
||||
# ----------------------------
|
||||
# Stage 1: PHP + Composer
|
||||
# ----------------------------
|
||||
FROM php:8.4-fpm AS php-base
|
||||
|
||||
WORKDIR /var/www/html
|
||||
|
||||
# Install system dependencies and PHP extensions
|
||||
RUN apt-get update && apt-get install -y \
|
||||
git curl libpng-dev libonig-dev libxml2-dev zip unzip \
|
||||
&& docker-php-ext-install pdo_mysql mbstring exif pcntl bcmath gd
|
||||
|
||||
# Install Composer
|
||||
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
|
||||
|
||||
# Copy app code
|
||||
COPY . .
|
||||
|
||||
# Install PHP dependencies (no dev)
|
||||
RUN composer install --no-dev --optimize-autoloader --no-interaction
|
||||
|
||||
|
||||
# ----------------------------
|
||||
# Stage 2: Node build
|
||||
# ----------------------------
|
||||
FROM node:20 AS frontend
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy only package files and install Node dependencies
|
||||
COPY package*.json ./
|
||||
RUN npm ci
|
||||
|
||||
# Copy the rest of the app code
|
||||
COPY . .
|
||||
|
||||
# Copy vendor from PHP stage (needed if assets reference PHP files)
|
||||
COPY --from=php-base /var/www/html/vendor ./vendor
|
||||
|
||||
# Build assets
|
||||
RUN npm run build
|
||||
|
||||
|
||||
# ----------------------------
|
||||
# Stage 3: Final production image
|
||||
# ----------------------------
|
||||
FROM php:8.4-fpm AS final
|
||||
|
||||
WORKDIR /var/www/html
|
||||
|
||||
# Install system deps and PHP extensions in the final image
|
||||
RUN apt-get update && apt-get install -y \
|
||||
git curl libpng-dev libonig-dev libxml2-dev zip unzip \
|
||||
&& docker-php-ext-install pdo_mysql mbstring exif pcntl bcmath gd
|
||||
|
||||
# Copy PHP code + vendor
|
||||
COPY --from=php-base /var/www/html .
|
||||
|
||||
# Copy built frontend assets
|
||||
COPY --from=frontend /app/public ./public
|
||||
|
||||
# Fix permissions for Laravel
|
||||
RUN chown -R www-data:www-data storage bootstrap/cache
|
||||
|
||||
# ----------------------------
|
||||
# Stage 4: Nginx with built assets
|
||||
# ----------------------------
|
||||
FROM nginx:1.27-alpine AS final-nginx
|
||||
|
||||
WORKDIR /var/www/html
|
||||
|
||||
# Copy built public folder from PHP image
|
||||
COPY --from=final /var/www/html/public ./public
|
||||
|
||||
# Copy nginx config
|
||||
COPY ./docker/nginx/nginx.conf /etc/nginx/conf.d/default.conf
|
||||
|
||||
# Expose HTTP port
|
||||
EXPOSE 80
|
||||
|
||||
# Start Nginx
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
||||
@@ -1,27 +0,0 @@
|
||||
services:
|
||||
app:
|
||||
image: git.oskarmikael.com/oskarb/scheduler:latest
|
||||
command: ["php-fpm"]
|
||||
volumes:
|
||||
- storage:/var/www/html/storage
|
||||
- bootstrap_cache:/var/www/html/bootstrap/cache
|
||||
- .env:/var/www/html/.env
|
||||
networks:
|
||||
- laravel
|
||||
|
||||
nginx:
|
||||
image: git.oskarmikael.com/oskarb/scheduler:latest
|
||||
ports:
|
||||
- '${APP_PORT:-80}:80'
|
||||
depends_on:
|
||||
- app
|
||||
networks:
|
||||
- laravel
|
||||
|
||||
networks:
|
||||
laravel:
|
||||
driver: bridge
|
||||
|
||||
volumes:
|
||||
storage:
|
||||
bootstrap_cache:
|
||||
@@ -1,21 +0,0 @@
|
||||
server {
|
||||
listen 80;
|
||||
server_name scheduler.oskarmikael.com;
|
||||
|
||||
root /var/www/html/public;
|
||||
index index.php index.html;
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ /index.php?$query_string;
|
||||
}
|
||||
|
||||
location ~ \.php$ {
|
||||
include fastcgi_params;
|
||||
fastcgi_pass app:9000;
|
||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||
}
|
||||
|
||||
location ~ /\.ht {
|
||||
deny all;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user