diff --git a/.env.docker b/.env.docker new file mode 100644 index 0000000..b332301 --- /dev/null +++ b/.env.docker @@ -0,0 +1,48 @@ +APP_NAME="PerceptronViewer" +APP_ENV=production +APP_KEY=base64:WE5DlJGDeIrl+B1ZqahVJSg4TN6oY3N1ph8CDKNo0w4= +APP_DEBUG=false +APP_URL=https://perceptron.matthiasg.dev + +APP_LOCALE=fr +APP_FALLBACK_LOCALE=fr +APP_FAKER_LOCALE=fr_FR + +APP_MAINTENANCE_DRIVER=file +# APP_MAINTENANCE_STORE=database + +LOG_CHANNEL=single +LOG_STACK=single +LOG_DEPRECATIONS_CHANNEL=null +LOG_LEVEL=debug + +SESSION_DRIVER=database +SESSION_LIFETIME=120 +SESSION_ENCRYPT=false +SESSION_PATH=/ + +BROADCAST_CONNECTION=reverb +FILESYSTEM_DISK=local +QUEUE_CONNECTION=database + +CACHE_STORE=database +# CACHE_PREFIX= + +MEMCACHED_HOST=memcached + +VITE_APP_NAME="${APP_NAME}" + +REVERB_SERVER_HOST=0.0.0.0 +REVERB_SERVER_PORT=8080 +REVERB_APP_ID=848245 +REVERB_APP_KEY=hkybzbkdvdl1hsvtzuqk +REVERB_APP_SECRET=oosuq0v9jgaslzp9cmhv +REVERB_HOST="perceptron.matthiasg.dev" +REVERB_PORT=443 +REVERB_SCHEME=https +REVERB_MAX_REQUEST_SIZE=100000 + +VITE_REVERB_APP_KEY="${REVERB_APP_KEY}" +VITE_REVERB_HOST="${REVERB_HOST}" +VITE_REVERB_PORT="${REVERB_PORT}" +VITE_REVERB_SCHEME="${REVERB_SCHEME}" diff --git a/.github/workflows/docker-publish.yaml b/.github/workflows/docker-publish.yaml new file mode 100644 index 0000000..d9c92d1 --- /dev/null +++ b/.github/workflows/docker-publish.yaml @@ -0,0 +1,49 @@ +name: Build and Push Docker Image + +on: + workflow_run: + workflows: ["tests"] + types: + - completed + +jobs: + build: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Get version + id: get_version + run: echo "::set-output name=version::$(cat VERSION)" + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Log in to Docker Hub + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + + - name: Build and push + uses: docker/build-push-action@v2 + with: + context: . + file: Dockerfile + push: true + tags: git.matthiasg.dev/Ninluc/perceptron-viewer/perceptron-viewer:latest, git.matthiasg.dev/Ninluc/perceptron-viewer/perceptron-viewer:${{ steps.get_version.outputs.version }} + + # notify: + # needs: build + # runs-on: ubuntu-latest + + # steps: + # - name: Notify Watchtower + # run: "curl -i -X POST -H \"Authorization: Bearer ${{ secrets.WATCHTOWER_TOKEN }}\" https://watchtower.beermaker.matthiasg.dev/v1/update" diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..e86f4fb --- /dev/null +++ b/Dockerfile @@ -0,0 +1,57 @@ +# Composer dependencies +FROM composer:2 AS vendor + +WORKDIR /usr/app +COPY . . +RUN composer install --no-dev --optimize-autoloader --no-interaction + +# Build frontend assets +# Install node and npm +RUN apk add --no-cache nodejs npm +RUN npm install +RUN npm run build + +# Final PHP image +FROM dunglas/frankenphp:1.12.2-php8.3-alpine AS final + +# Install system dependencies +RUN apk add --no-cache \ + bash \ + libpng-dev \ + libjpeg-turbo-dev \ + freetype-dev \ + oniguruma-dev \ + zip \ + unzip \ + git \ + curl \ + libpq-dev \ + php-pgsql + +# Install PHP extensions +RUN docker-php-ext-install pdo pgsql pdo_pgsql mbstring exif pcntl bcmath gd + +WORKDIR /app + +# Copy app +COPY . . + +RUN mv .env.docker .env + +# Copy dependencies +COPY --from=vendor /usr/app/vendor ./vendor + +# Copy built frontend +COPY --from=vendor /usr/app/public/build ./public/build + +# Permissions +#RUN chown -R www-data:www-data /app +#RUN chown www-data:www-data /app/dockerEntryPoint.sh +RUN chmod +x /app/dockerEntryPoint.sh + +HEALTHCHECK --interval=30s --timeout=30s --start-period=30s --retries=3 CMD curl -f http://127.0.0.1/up || exit 1 + +EXPOSE 80 +EXPOSE 8080 + +CMD ["./dockerEntryPoint.sh"] diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..3eefcb9 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +1.0.0 diff --git a/dockerEntryPoint.sh b/dockerEntryPoint.sh new file mode 100644 index 0000000..6c78d42 --- /dev/null +++ b/dockerEntryPoint.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +# Cache +php ./artisan optimize:clear && php ./artisan optimize + +# Start the server +exec frankenphp php-server --root=public