Add Docker and deployment configurations for development and production environments
Some checks failed
Deploy Production (crewsportswear.com) / deploy (push) Failing after 5m18s
Some checks failed
Deploy Production (crewsportswear.com) / deploy (push) Failing after 5m18s
This commit is contained in:
57
.gitea/workflows/build-push.yml
Normal file
57
.gitea/workflows/build-push.yml
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
name: Build and Push Docker Image
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- 'v*'
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
tag:
|
||||||
|
description: 'Docker image tag (e.g., v1.0.0, latest)'
|
||||||
|
required: false
|
||||||
|
default: 'latest'
|
||||||
|
push_to_registry:
|
||||||
|
description: 'Push to registry?'
|
||||||
|
required: false
|
||||||
|
default: 'true'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-and-push:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: catthehacker/ubuntu:act-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v2
|
||||||
|
|
||||||
|
- name: Login to Docker Registry
|
||||||
|
uses: docker/login-action@v2
|
||||||
|
with:
|
||||||
|
registry: ${{ secrets.DOCKER_REGISTRY_URL }}
|
||||||
|
username: ${{ secrets.DOCKER_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
|
|
||||||
|
- name: Extract metadata
|
||||||
|
id: meta
|
||||||
|
uses: docker/metadata-action@v4
|
||||||
|
with:
|
||||||
|
images: ${{ secrets.DOCKER_REGISTRY_URL }}/crewsportswear
|
||||||
|
tags: |
|
||||||
|
type=semver,pattern={{version}}
|
||||||
|
type=semver,pattern={{major}}.{{minor}}
|
||||||
|
type=semver,pattern={{major}}
|
||||||
|
type=raw,value=latest
|
||||||
|
|
||||||
|
- name: Build and push
|
||||||
|
uses: docker/build-push-action@v4
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
push: true
|
||||||
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
cache-from: type=registry,ref=${{ secrets.DOCKER_REGISTRY_URL }}/crewsportswear:buildcache
|
||||||
|
cache-to: type=registry,ref=${{ secrets.DOCKER_REGISTRY_URL }}/crewsportswear:buildcache,mode=max
|
||||||
152
.gitea/workflows/deploy-dev.yml
Normal file
152
.gitea/workflows/deploy-dev.yml
Normal file
@@ -0,0 +1,152 @@
|
|||||||
|
name: Deploy Development
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- dev
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
deploy:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: catthehacker/ubuntu:act-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
shell: sh
|
||||||
|
run: |
|
||||||
|
git clone $GITHUB_SERVER_URL/$GITHUB_REPOSITORY.git /workspace/repo
|
||||||
|
cd /workspace/repo
|
||||||
|
git checkout $GITHUB_REF_NAME
|
||||||
|
|
||||||
|
- name: Build Docker image
|
||||||
|
shell: sh
|
||||||
|
run: |
|
||||||
|
cd /workspace/repo
|
||||||
|
docker build -t crewsportswear:dev .
|
||||||
|
docker save crewsportswear:dev | gzip > crewsportswear_dev.tar.gz
|
||||||
|
|
||||||
|
- name: Setup SSH
|
||||||
|
shell: sh
|
||||||
|
env:
|
||||||
|
DEPLOY_SSH_KEY: ${{ secrets.DEPLOY_SSH_KEY }}
|
||||||
|
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
|
||||||
|
run: |
|
||||||
|
mkdir -p ~/.ssh
|
||||||
|
chmod 700 ~/.ssh
|
||||||
|
echo "$DEPLOY_SSH_KEY" > ~/.ssh/id_ed25519
|
||||||
|
chmod 600 ~/.ssh/id_ed25519
|
||||||
|
ssh-keyscan -H "$DEPLOY_HOST" >> ~/.ssh/known_hosts
|
||||||
|
|
||||||
|
- name: Upload image and compose
|
||||||
|
shell: sh
|
||||||
|
env:
|
||||||
|
DEPLOY_USER: ${{ secrets.DEPLOY_USER }}
|
||||||
|
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
|
||||||
|
run: |
|
||||||
|
scp -i ~/.ssh/id_ed25519 \
|
||||||
|
/workspace/repo/crewsportswear_dev.tar.gz \
|
||||||
|
/workspace/repo/docker-compose.dev.yml \
|
||||||
|
${DEPLOY_USER}@${DEPLOY_HOST}:/tmp/
|
||||||
|
|
||||||
|
- name: Deploy on server
|
||||||
|
shell: sh
|
||||||
|
env:
|
||||||
|
DEPLOY_USER: ${{ secrets.DEPLOY_USER }}
|
||||||
|
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
|
||||||
|
|
||||||
|
run: |
|
||||||
|
ssh -i ~/.ssh/id_ed25519 $DEPLOY_USER@$DEPLOY_HOST << 'EOF'
|
||||||
|
set -e
|
||||||
|
|
||||||
|
DEPLOY_DIR="/var/www/apps/crewsportswear_dev"
|
||||||
|
mkdir -p "$DEPLOY_DIR"
|
||||||
|
|
||||||
|
echo "Loading image"
|
||||||
|
docker load < /tmp/crewsportswear_dev.tar.gz
|
||||||
|
|
||||||
|
echo "Removing old crewsportswear images"
|
||||||
|
docker images | grep crewsportswear | grep -v "$(docker images crewsportswear:dev -q)" | awk '{print $3}' | xargs -r docker rmi -f || true
|
||||||
|
|
||||||
|
echo "Updating compose file"
|
||||||
|
cp /tmp/docker-compose.dev.yml "$DEPLOY_DIR/docker-compose.yml"
|
||||||
|
|
||||||
|
cd "$DEPLOY_DIR"
|
||||||
|
|
||||||
|
echo "Checking .env file"
|
||||||
|
if [ ! -f .env ]; then
|
||||||
|
echo ".env file not found at $DEPLOY_DIR/.env"
|
||||||
|
echo "Please create it first with required variables:"
|
||||||
|
echo " - DB_*, PROD_PRIVATE, IMAGES_URL, UPLOAD_URL"
|
||||||
|
echo " - MAIL_*, CAPTCHA_*, ANALYTICS_*"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Fixing .env permissions"
|
||||||
|
sudo chown $USER:$USER .env
|
||||||
|
sudo chmod 600 .env
|
||||||
|
|
||||||
|
echo "Ensure networks"
|
||||||
|
docker network inspect traefik-public >/dev/null 2>&1 || \
|
||||||
|
docker network create traefik-public
|
||||||
|
docker network inspect crew-app-net >/dev/null 2>&1 || \
|
||||||
|
docker network create crew-app-net
|
||||||
|
|
||||||
|
echo "Starting containers (env vars from .env file)"
|
||||||
|
docker compose up -d
|
||||||
|
|
||||||
|
echo "Waiting for app container"
|
||||||
|
sleep 15
|
||||||
|
|
||||||
|
if docker ps --format '{{.Names}}' | grep -q crewsportswear_app; then
|
||||||
|
echo "Clearing and rebuilding config cache"
|
||||||
|
docker compose exec -T app php artisan config:clear
|
||||||
|
docker compose exec -T app php artisan config:cache
|
||||||
|
else
|
||||||
|
echo "App container not running"
|
||||||
|
docker compose logs
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Cleanup"
|
||||||
|
rm -f /tmp/crewsportswear_dev.tar.gz /tmp/docker-compose.dev.yml
|
||||||
|
|
||||||
|
echo "Aggressive Docker cleanup to reclaim space"
|
||||||
|
docker image prune -af --filter "until=24h" || true
|
||||||
|
docker container prune -f || true
|
||||||
|
docker volume prune -f || true
|
||||||
|
docker builder prune -af --filter "until=48h" || true
|
||||||
|
echo "Docker space usage:"
|
||||||
|
docker system df
|
||||||
|
|
||||||
|
echo "Deployment completed"
|
||||||
|
EOF
|
||||||
|
|
||||||
|
|
||||||
|
- name: Health check
|
||||||
|
shell: sh
|
||||||
|
run: |
|
||||||
|
echo "Waiting for app to be ready..."
|
||||||
|
sleep 20
|
||||||
|
|
||||||
|
echo "Testing health check (ignoring SSL cert for now)..."
|
||||||
|
HTTP_CODE=$(curl -k -s -o /dev/null -w "%{http_code}" --max-time 30 https://dev.crewsportswear.app || echo "000")
|
||||||
|
|
||||||
|
if [ "$HTTP_CODE" = "200" ] || [ "$HTTP_CODE" = "302" ] || [ "$HTTP_CODE" = "301" ]; then
|
||||||
|
echo "Health check passed! (HTTP $HTTP_CODE)"
|
||||||
|
echo "Note: Using -k to ignore SSL cert. Check Traefik logs if cert not ready."
|
||||||
|
else
|
||||||
|
echo "Health check failed! (HTTP $HTTP_CODE)"
|
||||||
|
echo ""
|
||||||
|
echo "Troubleshooting:"
|
||||||
|
echo " 1. Check if container is running:"
|
||||||
|
echo " docker ps | grep crewsportswear_app"
|
||||||
|
echo " 2. Check container logs:"
|
||||||
|
echo " docker logs crewsportswear_app_dev"
|
||||||
|
echo " 3. Check Traefik routing:"
|
||||||
|
echo " docker logs traefik 2>&1 | grep crewsportswear"
|
||||||
|
echo " 4. Verify network connectivity:"
|
||||||
|
echo " docker network inspect traefik-public"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
145
.gitea/workflows/deploy.yml
Normal file
145
.gitea/workflows/deploy.yml
Normal file
@@ -0,0 +1,145 @@
|
|||||||
|
name: Deploy Production (crewsportswear.com)
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
- master
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
deploy:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: catthehacker/ubuntu:act-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
shell: sh
|
||||||
|
run: |
|
||||||
|
git clone $GITHUB_SERVER_URL/$GITHUB_REPOSITORY.git /workspace/repo
|
||||||
|
cd /workspace/repo
|
||||||
|
git checkout $GITHUB_REF_NAME
|
||||||
|
|
||||||
|
- name: Build Docker image
|
||||||
|
shell: sh
|
||||||
|
run: |
|
||||||
|
cd /workspace/repo
|
||||||
|
docker build -t crewsportswear:latest .
|
||||||
|
docker save crewsportswear:latest | gzip > crewsportswear.tar.gz
|
||||||
|
|
||||||
|
- name: Setup SSH
|
||||||
|
shell: sh
|
||||||
|
env:
|
||||||
|
DEPLOY_SSH_KEY: ${{ secrets.DEPLOY_SSH_KEY }}
|
||||||
|
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
|
||||||
|
run: |
|
||||||
|
mkdir -p ~/.ssh
|
||||||
|
chmod 700 ~/.ssh
|
||||||
|
echo "$DEPLOY_SSH_KEY" > ~/.ssh/id_ed25519
|
||||||
|
chmod 600 ~/.ssh/id_ed25519
|
||||||
|
ssh-keyscan -H "$DEPLOY_HOST" >> ~/.ssh/known_hosts
|
||||||
|
|
||||||
|
- name: Upload image and compose
|
||||||
|
shell: sh
|
||||||
|
env:
|
||||||
|
DEPLOY_USER: ${{ secrets.DEPLOY_USER }}
|
||||||
|
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
|
||||||
|
run: |
|
||||||
|
scp -i ~/.ssh/id_ed25519 \
|
||||||
|
/workspace/repo/crewsportswear.tar.gz \
|
||||||
|
/workspace/repo/docker-compose.prod.yml \
|
||||||
|
${DEPLOY_USER}@${DEPLOY_HOST}:/tmp/
|
||||||
|
|
||||||
|
- name: Deploy on server
|
||||||
|
shell: sh
|
||||||
|
env:
|
||||||
|
DEPLOY_USER: ${{ secrets.DEPLOY_USER }}
|
||||||
|
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
|
||||||
|
|
||||||
|
run: |
|
||||||
|
ssh -i ~/.ssh/id_ed25519 $DEPLOY_USER@$DEPLOY_HOST << 'EOF'
|
||||||
|
set -e
|
||||||
|
|
||||||
|
DEPLOY_DIR="/var/www/crewsportswear"
|
||||||
|
sudo mkdir -p "$DEPLOY_DIR"
|
||||||
|
sudo chown $USER:$USER "$DEPLOY_DIR"
|
||||||
|
|
||||||
|
echo "Stopping dev environment"
|
||||||
|
DEV_DIR="/var/www/apps/crewsportswear_dev"
|
||||||
|
if [ -d "$DEV_DIR" ]; then
|
||||||
|
cd "$DEV_DIR"
|
||||||
|
docker compose down || true
|
||||||
|
cd -
|
||||||
|
echo "Dev environment stopped"
|
||||||
|
echo "Copying .env from dev to production"
|
||||||
|
if [ -f "$DEV_DIR/.env" ]; then
|
||||||
|
cp "$DEV_DIR/.env" "$DEPLOY_DIR/.env"
|
||||||
|
echo ".env file copied from dev to production"
|
||||||
|
else
|
||||||
|
echo "No .env file found in dev directory"
|
||||||
|
fi else
|
||||||
|
echo "No dev environment found"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Loading image"
|
||||||
|
docker load < /tmp/crewsportswear.tar.gz
|
||||||
|
|
||||||
|
echo "Removing dev images and old crewsportswear images"
|
||||||
|
docker images | grep "crewsportswear:dev" | awk '{print $3}' | xargs -r docker rmi -f || true
|
||||||
|
docker images | grep crewsportswear | grep -v "$(docker images crewsportswear:latest -q)" | awk '{print $3}' | xargs -r docker rmi -f || true
|
||||||
|
|
||||||
|
echo "Updating compose file"
|
||||||
|
cp /tmp/docker-compose.prod.yml "$DEPLOY_DIR/docker-compose.yml"
|
||||||
|
|
||||||
|
cd "$DEPLOY_DIR"
|
||||||
|
|
||||||
|
echo "Checking .env file"
|
||||||
|
if [ ! -f .env ]; then
|
||||||
|
echo ".env file not found at $DEPLOY_DIR/.env"
|
||||||
|
echo "Please create it first with required variables:"
|
||||||
|
echo " - DB_*, PROD_PRIVATE, IMAGES_URL, UPLOAD_URL"
|
||||||
|
echo " - MAIL_*, CAPTCHA_*, ANALYTICS_*"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Fixing .env permissions"
|
||||||
|
sudo chown $USER:$USER .env
|
||||||
|
sudo chmod 600 .env
|
||||||
|
|
||||||
|
echo "Ensure networks"
|
||||||
|
docker network inspect traefik-public >/dev/null 2>&1 || \
|
||||||
|
docker network create traefik-public
|
||||||
|
docker network inspect crew-app-net >/dev/null 2>&1 || \
|
||||||
|
docker network create crew-app-net
|
||||||
|
|
||||||
|
echo "Starting containers (env vars from .env file)"
|
||||||
|
docker compose up -d
|
||||||
|
|
||||||
|
echo "Waiting for app container"
|
||||||
|
sleep 15
|
||||||
|
|
||||||
|
if docker ps --format '{{.Names}}' | grep -q crewsportswear_app; then
|
||||||
|
echo "Clearing and rebuilding config cache"
|
||||||
|
docker compose exec -T app php artisan config:clear
|
||||||
|
docker compose exec -T app php artisan config:cache
|
||||||
|
else
|
||||||
|
echo "App container not running"
|
||||||
|
docker compose logs
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Cleanup"
|
||||||
|
rm -f /tmp/crewsportswear.tar.gz /tmp/docker-compose.prod.yml
|
||||||
|
|
||||||
|
echo "Aggressive Docker cleanup to reclaim space"
|
||||||
|
docker image prune -af --filter "until=24h" || true
|
||||||
|
docker container prune -f || true
|
||||||
|
docker volume prune -f || true
|
||||||
|
docker builder prune -af --filter "until=48h" || true
|
||||||
|
echo "Docker space usage:"
|
||||||
|
docker system df
|
||||||
|
|
||||||
|
echo "Production deployment completed!"
|
||||||
|
echo "Application available at: https://crewsportswear.com"
|
||||||
|
EOF
|
||||||
123
Dockerfile
Normal file
123
Dockerfile
Normal file
@@ -0,0 +1,123 @@
|
|||||||
|
# Use PHP 7.0 with Apache (has native mcrypt support for Laravel 5.0)
|
||||||
|
FROM php:7.0-apache
|
||||||
|
|
||||||
|
# Update to use archived Debian repositories
|
||||||
|
RUN sed -i 's|deb.debian.org|archive.debian.org|g' /etc/apt/sources.list \
|
||||||
|
&& sed -i 's|security.debian.org|archive.debian.org|g' /etc/apt/sources.list \
|
||||||
|
&& sed -i '/stretch-updates/d' /etc/apt/sources.list
|
||||||
|
|
||||||
|
# Install system dependencies
|
||||||
|
RUN apt-get update && apt-get install -y --allow-unauthenticated \
|
||||||
|
git \
|
||||||
|
curl \
|
||||||
|
libpng-dev \
|
||||||
|
libxml2-dev \
|
||||||
|
libmcrypt-dev \
|
||||||
|
zip \
|
||||||
|
unzip \
|
||||||
|
libfreetype6-dev \
|
||||||
|
libjpeg62-turbo-dev \
|
||||||
|
openssh-client \
|
||||||
|
&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
|
||||||
|
&& docker-php-ext-install -j$(nproc) gd
|
||||||
|
|
||||||
|
# Install PHP extensions (mcrypt is built-in for PHP 7.0)
|
||||||
|
RUN docker-php-ext-install pdo_mysql mbstring exif pcntl bcmath mcrypt tokenizer zip
|
||||||
|
|
||||||
|
# Enable Apache mod_rewrite
|
||||||
|
RUN a2enmod rewrite
|
||||||
|
|
||||||
|
# Install Composer (version 1.x for better compatibility with Laravel 5.0)
|
||||||
|
COPY --from=composer:1.10 /usr/bin/composer /usr/bin/composer
|
||||||
|
|
||||||
|
# Set working directory
|
||||||
|
WORKDIR /var/www/html
|
||||||
|
|
||||||
|
# Copy existing application directory contents
|
||||||
|
COPY . /var/www/html
|
||||||
|
|
||||||
|
# Create storage directories and set permissions
|
||||||
|
RUN mkdir -p storage/framework/views \
|
||||||
|
storage/framework/cache \
|
||||||
|
storage/framework/sessions \
|
||||||
|
storage/logs \
|
||||||
|
bootstrap/cache
|
||||||
|
|
||||||
|
# Set proper ownership and permissions
|
||||||
|
RUN chown -R www-data:www-data /var/www/html \
|
||||||
|
&& chmod -R 775 /var/www/html/storage \
|
||||||
|
&& chmod -R 775 /var/www/html/bootstrap/cache
|
||||||
|
|
||||||
|
# Create .env file if it doesn't exist
|
||||||
|
RUN if [ ! -f .env ]; then cp .env.example .env; fi
|
||||||
|
|
||||||
|
# Install PHP dependencies (Laravel 5.0 compatible)
|
||||||
|
RUN composer install --no-dev --no-interaction --prefer-dist
|
||||||
|
|
||||||
|
# Generate application key
|
||||||
|
RUN php artisan key:generate || true
|
||||||
|
|
||||||
|
# Run Laravel 5.0 optimization
|
||||||
|
RUN php artisan clear-compiled && php artisan optimize
|
||||||
|
|
||||||
|
# Note: yakpro-po obfuscation requires PHP 7.1+, incompatible with PHP 7.0
|
||||||
|
# For code protection with PHP 7.0, consider:
|
||||||
|
# 1. ionCube Encoder (commercial, most secure)
|
||||||
|
# 2. Keeping source code private and using proper access controls
|
||||||
|
# 3. Using --optimize flag in composer (already done above)
|
||||||
|
|
||||||
|
# Configure Apache DocumentRoot to point to Laravel's public directory
|
||||||
|
ENV APACHE_DOCUMENT_ROOT=/var/www/html/public
|
||||||
|
RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/*.conf
|
||||||
|
RUN sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf
|
||||||
|
|
||||||
|
# Suppress Apache ServerName warning
|
||||||
|
RUN echo "ServerName localhost" >> /etc/apache2/apache2.conf
|
||||||
|
|
||||||
|
# Copy entrypoint script
|
||||||
|
COPY docker-entrypoint.sh /usr/local/bin/
|
||||||
|
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
|
||||||
|
|
||||||
|
# Expose port 80
|
||||||
|
EXPOSE 80
|
||||||
|
|
||||||
|
# Use entrypoint to set up permissions before starting Apache
|
||||||
|
ENTRYPOINT ["docker-entrypoint.sh"]
|
||||||
|
CMD ["apache2-foreground"]
|
||||||
|
|
||||||
|
# Create .env file if it doesn't exist
|
||||||
|
RUN if [ ! -f .env ]; then cp .env.example .env; fi
|
||||||
|
|
||||||
|
# Install PHP dependencies (Laravel 5.0 compatible)
|
||||||
|
RUN composer install --no-dev --no-interaction --prefer-dist
|
||||||
|
|
||||||
|
# Generate application key
|
||||||
|
RUN php artisan key:generate || true
|
||||||
|
|
||||||
|
# Run Laravel 5.0 optimization
|
||||||
|
RUN php artisan clear-compiled && php artisan optimize
|
||||||
|
|
||||||
|
# Note: yakpro-po obfuscation requires PHP 7.1+, incompatible with PHP 7.0
|
||||||
|
# For code protection with PHP 7.0, consider:
|
||||||
|
# 1. ionCube Encoder (commercial, most secure)
|
||||||
|
# 2. Keeping source code private and using proper access controls
|
||||||
|
# 3. Using --optimize flag in composer (already done above)
|
||||||
|
|
||||||
|
# Configure Apache DocumentRoot to point to Laravel's public directory
|
||||||
|
ENV APACHE_DOCUMENT_ROOT=/var/www/html/public
|
||||||
|
RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/*.conf
|
||||||
|
RUN sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf
|
||||||
|
|
||||||
|
# Suppress Apache ServerName warning
|
||||||
|
RUN echo "ServerName localhost" >> /etc/apache2/apache2.conf
|
||||||
|
|
||||||
|
# Copy entrypoint script
|
||||||
|
COPY docker-entrypoint.sh /usr/local/bin/
|
||||||
|
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
|
||||||
|
|
||||||
|
# Expose port 80
|
||||||
|
EXPOSE 80
|
||||||
|
|
||||||
|
# Use entrypoint to set up permissions before starting Apache
|
||||||
|
ENTRYPOINT ["docker-entrypoint.sh"]
|
||||||
|
CMD ["apache2-foreground"]
|
||||||
114
docker-compose.dev.yml
Normal file
114
docker-compose.dev.yml
Normal file
@@ -0,0 +1,114 @@
|
|||||||
|
services:
|
||||||
|
app:
|
||||||
|
image: crewsportswear:dev
|
||||||
|
container_name: crewsportswear_app_dev
|
||||||
|
restart: unless-stopped
|
||||||
|
environment:
|
||||||
|
- APP_ENV=${APP_ENV:-development}
|
||||||
|
- APP_DEBUG=${APP_DEBUG:-true}
|
||||||
|
- APP_URL=${APP_URL:-https://dev.crewsportswear.app}
|
||||||
|
- DB_CONNECTION=mysql
|
||||||
|
- DB_HOST=${DB_HOST}
|
||||||
|
- DB_PORT=${DB_PORT:-3306}
|
||||||
|
- DB_DATABASE=${DB_DATABASE}
|
||||||
|
- DB_USERNAME=${DB_USERNAME}
|
||||||
|
- DB_PASSWORD=${DB_PASSWORD}
|
||||||
|
- PROD_PRIVATE=${PROD_PRIVATE}
|
||||||
|
- IMAGES_URL=${IMAGES_URL}
|
||||||
|
- UPLOAD_URL=${UPLOAD_URL}
|
||||||
|
- FORCE_HTTPS=true
|
||||||
|
- MAIL_DRIVER=${MAIL_DRIVER}
|
||||||
|
- MAIL_HOST=${MAIL_HOST}
|
||||||
|
- MAIL_PORT=${MAIL_PORT}
|
||||||
|
- MAIL_USERNAME=${MAIL_USERNAME}
|
||||||
|
- MAIL_PASSWORD=${MAIL_PASSWORD}
|
||||||
|
- MAIL_ENCRYPTION=${MAIL_ENCRYPTION}
|
||||||
|
- CAPTCHA_SITE_KEY=${CAPTCHA_SITE_KEY}
|
||||||
|
- CAPTCHA_SECRET_KEY=${CAPTCHA_SECRET_KEY}
|
||||||
|
- ANALYTICS_SITE_ID=${ANALYTICS_SITE_ID}
|
||||||
|
- ANALYTICS_CLIENT_ID=${ANALYTICS_CLIENT_ID}
|
||||||
|
- ANALYTICS_SERVICE_EMAIL=${ANALYTICS_SERVICE_EMAIL}
|
||||||
|
volumes:
|
||||||
|
- ./storage:/var/www/html/storage
|
||||||
|
- ./public/uploads:/var/www/html/public/uploads
|
||||||
|
labels:
|
||||||
|
- "traefik.enable=true"
|
||||||
|
# Development environment (dev.crewsportswear.app)
|
||||||
|
- "traefik.http.routers.crewsportswear-dev.rule=Host(`dev.crewsportswear.app`)"
|
||||||
|
- "traefik.http.routers.crewsportswear-dev.entrypoints=websecure"
|
||||||
|
- "traefik.http.routers.crewsportswear-dev.tls=true"
|
||||||
|
- "traefik.http.routers.crewsportswear-dev.tls.certresolver=le"
|
||||||
|
- "traefik.http.services.crewsportswear-dev.loadbalancer.server.port=80"
|
||||||
|
# HTTP to HTTPS redirect
|
||||||
|
- "traefik.http.routers.crewsportswear-dev-http.rule=Host(`dev.crewsportswear.app`)"
|
||||||
|
- "traefik.http.routers.crewsportswear-dev-http.entrypoints=web"
|
||||||
|
- "traefik.http.routers.crewsportswear-dev-http.middlewares=https-redirect"
|
||||||
|
- "traefik.http.middlewares.https-redirect.redirectscheme.scheme=https"
|
||||||
|
networks:
|
||||||
|
- traefik-public
|
||||||
|
- crew-app-net
|
||||||
|
- default
|
||||||
|
|
||||||
|
networks:
|
||||||
|
traefik-public:
|
||||||
|
external: true
|
||||||
|
crew-app-net:
|
||||||
|
external: true
|
||||||
|
default:
|
||||||
|
driver: bridge
|
||||||
|
image: crewsportswear:dev
|
||||||
|
container_name: crewsportswear_app_dev
|
||||||
|
restart: unless-stopped
|
||||||
|
environment:
|
||||||
|
- APP_ENV=${APP_ENV:-development}
|
||||||
|
- APP_DEBUG=${APP_DEBUG:-true}
|
||||||
|
- APP_URL=${APP_URL:-https://dev.crewsportswear.com}
|
||||||
|
- DB_CONNECTION=mysql
|
||||||
|
- DB_HOST=${DB_HOST}
|
||||||
|
- DB_PORT=${DB_PORT:-3306}
|
||||||
|
- DB_DATABASE=${DB_DATABASE}
|
||||||
|
- DB_USERNAME=${DB_USERNAME}
|
||||||
|
- DB_PASSWORD=${DB_PASSWORD}
|
||||||
|
- PROD_PRIVATE=${PROD_PRIVATE}
|
||||||
|
- IMAGES_URL=${IMAGES_URL}
|
||||||
|
- UPLOAD_URL=${UPLOAD_URL}
|
||||||
|
- FORCE_HTTPS=true
|
||||||
|
- MAIL_DRIVER=${MAIL_DRIVER}
|
||||||
|
- MAIL_HOST=${MAIL_HOST}
|
||||||
|
- MAIL_PORT=${MAIL_PORT}
|
||||||
|
- MAIL_USERNAME=${MAIL_USERNAME}
|
||||||
|
- MAIL_PASSWORD=${MAIL_PASSWORD}
|
||||||
|
- MAIL_ENCRYPTION=${MAIL_ENCRYPTION}
|
||||||
|
- CAPTCHA_SITE_KEY=${CAPTCHA_SITE_KEY}
|
||||||
|
- CAPTCHA_SECRET_KEY=${CAPTCHA_SECRET_KEY}
|
||||||
|
- ANALYTICS_SITE_ID=${ANALYTICS_SITE_ID}
|
||||||
|
- ANALYTICS_CLIENT_ID=${ANALYTICS_CLIENT_ID}
|
||||||
|
- ANALYTICS_SERVICE_EMAIL=${ANALYTICS_SERVICE_EMAIL}
|
||||||
|
volumes:
|
||||||
|
- ./storage:/var/www/html/storage
|
||||||
|
- ./public/uploads:/var/www/html/public/uploads
|
||||||
|
labels:
|
||||||
|
- "traefik.enable=true"
|
||||||
|
# Development environment (dev.crewsportswear.com)
|
||||||
|
- "traefik.http.routers.crewsportswear-dev.rule=Host(`dev.crewsportswear.com`)"
|
||||||
|
- "traefik.http.routers.crewsportswear-dev.entrypoints=websecure"
|
||||||
|
- "traefik.http.routers.crewsportswear-dev.tls=true"
|
||||||
|
- "traefik.http.routers.crewsportswear-dev.tls.certresolver=letsencrypt"
|
||||||
|
- "traefik.http.services.crewsportswear-dev.loadbalancer.server.port=80"
|
||||||
|
# HTTP to HTTPS redirect
|
||||||
|
- "traefik.http.routers.crewsportswear-dev-http.rule=Host(`dev.crewsportswear.com`)"
|
||||||
|
- "traefik.http.routers.crewsportswear-dev-http.entrypoints=web"
|
||||||
|
- "traefik.http.routers.crewsportswear-dev-http.middlewares=https-redirect"
|
||||||
|
- "traefik.http.middlewares.https-redirect.redirectscheme.scheme=https"
|
||||||
|
networks:
|
||||||
|
- traefik-public
|
||||||
|
- crew-app-net
|
||||||
|
- default
|
||||||
|
|
||||||
|
networks:
|
||||||
|
traefik-public:
|
||||||
|
external: true
|
||||||
|
crew-app-net:
|
||||||
|
external: true
|
||||||
|
default:
|
||||||
|
driver: bridge
|
||||||
81
docker-compose.local.yml
Normal file
81
docker-compose.local.yml
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
services:
|
||||||
|
db:
|
||||||
|
image: mariadb:10.6
|
||||||
|
platform: linux/arm64
|
||||||
|
container_name: crewsportswear_db_local
|
||||||
|
restart: unless-stopped
|
||||||
|
environment:
|
||||||
|
MYSQL_DATABASE: crewsportswear
|
||||||
|
MYSQL_ROOT_PASSWORD: root
|
||||||
|
MYSQL_USER: crewsportswear
|
||||||
|
MYSQL_PASSWORD: secret
|
||||||
|
ports:
|
||||||
|
- "3307:3306"
|
||||||
|
volumes:
|
||||||
|
- db_data:/var/lib/mysql
|
||||||
|
networks:
|
||||||
|
- crewsportswear-local
|
||||||
|
|
||||||
|
app:
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
container_name: crewsportswear_app_local
|
||||||
|
restart: unless-stopped
|
||||||
|
ports:
|
||||||
|
- "8082:80"
|
||||||
|
environment:
|
||||||
|
- APP_ENV=local
|
||||||
|
- APP_DEBUG=true
|
||||||
|
- APP_URL=http://localhost:8082
|
||||||
|
- DB_CONNECTION=mysql
|
||||||
|
- DB_HOST=db
|
||||||
|
- DB_PORT=3306
|
||||||
|
- DB_DATABASE=crewsportswear
|
||||||
|
- DB_USERNAME=crewsportswear
|
||||||
|
- DB_PASSWORD=secret
|
||||||
|
- PROD_PRIVATE=http://localhost:8082
|
||||||
|
- IMAGES_URL=http://localhost:8082
|
||||||
|
- UPLOAD_URL=http://localhost:8082/uploads/
|
||||||
|
- MAIL_DRIVER=log
|
||||||
|
- MAIL_HOST=localhost
|
||||||
|
- MAIL_PORT=1025
|
||||||
|
- MAIL_USERNAME=null
|
||||||
|
- MAIL_PASSWORD=null
|
||||||
|
- MAIL_ENCRYPTION=null
|
||||||
|
- CAPTCHA_SITE_KEY=test_key
|
||||||
|
- CAPTCHA_SECRET_KEY=test_secret
|
||||||
|
- ANALYTICS_SITE_ID=
|
||||||
|
- ANALYTICS_CLIENT_ID=
|
||||||
|
- ANALYTICS_SERVICE_EMAIL=
|
||||||
|
volumes:
|
||||||
|
- ./:/var/www/html
|
||||||
|
- ./storage:/var/www/html/storage
|
||||||
|
- ./public/uploads:/var/www/html/public/uploads
|
||||||
|
depends_on:
|
||||||
|
- db
|
||||||
|
networks:
|
||||||
|
- crewsportswear-local
|
||||||
|
|
||||||
|
phpmyadmin:
|
||||||
|
image: arm64v8/phpmyadmin
|
||||||
|
platform: linux/arm64
|
||||||
|
container_name: crewsportswear_phpmyadmin
|
||||||
|
restart: unless-stopped
|
||||||
|
ports:
|
||||||
|
- "8083:80"
|
||||||
|
environment:
|
||||||
|
PMA_HOST: db
|
||||||
|
PMA_PORT: 3306
|
||||||
|
MYSQL_ROOT_PASSWORD: root
|
||||||
|
depends_on:
|
||||||
|
- db
|
||||||
|
networks:
|
||||||
|
- crewsportswear-local
|
||||||
|
|
||||||
|
networks:
|
||||||
|
crewsportswear-local:
|
||||||
|
driver: bridge
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
db_data:
|
||||||
57
docker-compose.prod.yml
Normal file
57
docker-compose.prod.yml
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
services:
|
||||||
|
app:
|
||||||
|
image: crewsportswear:latest
|
||||||
|
container_name: crewsportswear_app_prod
|
||||||
|
restart: unless-stopped
|
||||||
|
environment:
|
||||||
|
- APP_ENV=${APP_ENV:-production}
|
||||||
|
- APP_DEBUG=${APP_DEBUG:-false}
|
||||||
|
- APP_URL=${APP_URL:-https://crewsportswear.com}
|
||||||
|
- DB_CONNECTION=mysql
|
||||||
|
- DB_HOST=${DB_HOST}
|
||||||
|
- DB_PORT=${DB_PORT:-3306}
|
||||||
|
- DB_DATABASE=${DB_DATABASE}
|
||||||
|
- DB_USERNAME=${DB_USERNAME}
|
||||||
|
- DB_PASSWORD=${DB_PASSWORD}
|
||||||
|
- PROD_PRIVATE=${PROD_PRIVATE}
|
||||||
|
- IMAGES_URL=${IMAGES_URL}
|
||||||
|
- UPLOAD_URL=${UPLOAD_URL}
|
||||||
|
- FORCE_HTTPS=true
|
||||||
|
- MAIL_DRIVER=${MAIL_DRIVER}
|
||||||
|
- MAIL_HOST=${MAIL_HOST}
|
||||||
|
- MAIL_PORT=${MAIL_PORT}
|
||||||
|
- MAIL_USERNAME=${MAIL_USERNAME}
|
||||||
|
- MAIL_PASSWORD=${MAIL_PASSWORD}
|
||||||
|
- MAIL_ENCRYPTION=${MAIL_ENCRYPTION}
|
||||||
|
- CAPTCHA_SITE_KEY=${CAPTCHA_SITE_KEY}
|
||||||
|
- CAPTCHA_SECRET_KEY=${CAPTCHA_SECRET_KEY}
|
||||||
|
- ANALYTICS_SITE_ID=${ANALYTICS_SITE_ID}
|
||||||
|
- ANALYTICS_CLIENT_ID=${ANALYTICS_CLIENT_ID}
|
||||||
|
- ANALYTICS_SERVICE_EMAIL=${ANALYTICS_SERVICE_EMAIL}
|
||||||
|
volumes:
|
||||||
|
- ./storage:/var/www/html/storage
|
||||||
|
- ./public/uploads:/var/www/html/public/uploads
|
||||||
|
labels:
|
||||||
|
- "traefik.enable=true"
|
||||||
|
# Production environment (crewsportswear.com) - Uses DigiCert SSL
|
||||||
|
- "traefik.http.routers.crewsportswear-prod.rule=Host(`crewsportswear.com`) || Host(`www.crewsportswear.com`)"
|
||||||
|
- "traefik.http.routers.crewsportswear-prod.entrypoints=websecure"
|
||||||
|
- "traefik.http.routers.crewsportswear-prod.tls=true"
|
||||||
|
- "traefik.http.services.crewsportswear-prod.loadbalancer.server.port=80"
|
||||||
|
# HTTP to HTTPS redirect
|
||||||
|
- "traefik.http.routers.crewsportswear-prod-http.rule=Host(`crewsportswear.com`) || Host(`www.crewsportswear.com`)"
|
||||||
|
- "traefik.http.routers.crewsportswear-prod-http.entrypoints=web"
|
||||||
|
- "traefik.http.routers.crewsportswear-prod-http.middlewares=https-redirect"
|
||||||
|
- "traefik.http.middlewares.https-redirect.redirectscheme.scheme=https"
|
||||||
|
networks:
|
||||||
|
- traefik-public
|
||||||
|
- crew-app-net
|
||||||
|
- default
|
||||||
|
|
||||||
|
networks:
|
||||||
|
traefik-public:
|
||||||
|
external: true
|
||||||
|
crew-app-net:
|
||||||
|
external: true
|
||||||
|
default:
|
||||||
|
driver: bridge
|
||||||
17
docker-entrypoint.sh
Normal file
17
docker-entrypoint.sh
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# Create storage directory structure if it doesn't exist
|
||||||
|
mkdir -p storage/framework/views
|
||||||
|
mkdir -p storage/framework/cache
|
||||||
|
mkdir -p storage/framework/sessions
|
||||||
|
mkdir -p storage/logs
|
||||||
|
mkdir -p storage/app/public
|
||||||
|
mkdir -p bootstrap/cache
|
||||||
|
|
||||||
|
# Set proper permissions
|
||||||
|
chown -R www-data:www-data storage bootstrap/cache
|
||||||
|
chmod -R 775 storage bootstrap/cache
|
||||||
|
|
||||||
|
# Execute the main command
|
||||||
|
exec "$@"
|
||||||
0
storage/.gitignore
vendored
Normal file → Executable file
0
storage/.gitignore
vendored
Normal file → Executable file
0
storage/app/.gitignore
vendored
Normal file → Executable file
0
storage/app/.gitignore
vendored
Normal file → Executable file
0
storage/framework/.gitignore
vendored
Normal file → Executable file
0
storage/framework/.gitignore
vendored
Normal file → Executable file
0
storage/framework/cache/.gitignore
vendored
Normal file → Executable file
0
storage/framework/cache/.gitignore
vendored
Normal file → Executable file
0
storage/framework/sessions/.gitignore
vendored
Normal file → Executable file
0
storage/framework/sessions/.gitignore
vendored
Normal file → Executable file
0
storage/framework/views/.gitignore
vendored
Normal file → Executable file
0
storage/framework/views/.gitignore
vendored
Normal file → Executable file
0
storage/laravel-analytics/hardy-beach-228905-7755a62c7a35.p12
Normal file → Executable file
0
storage/laravel-analytics/hardy-beach-228905-7755a62c7a35.p12
Normal file → Executable file
0
storage/logs/.gitignore
vendored
Normal file → Executable file
0
storage/logs/.gitignore
vendored
Normal file → Executable file
Reference in New Issue
Block a user