diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..92b433a --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,125 @@ +name: Build Docker Image + +on: [push] + +env: + REGISTRY: ghcr.io + IMAGE_NAME: strichliste + BRANCH: "wamp" + +jobs: + build-frontend: + name: Build Frontend + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + repository: "Westwoodlabs/strichliste-web-frontend" + ref: ${{ env.BRANCH }} + + - name: Use Node.js + uses: actions/setup-node@v4 + + - name: Install dependencies + run: yarn install + + - name: Build Frontend + run: | + export NODE_OPTIONS=--openssl-legacy-provider + CI=false yarn build + + - name: Display structure of files + run: ls -R + + - name: Upload build artifacts + uses: actions/upload-artifact@v3 + with: + name: frontend + path: build + + build-backend: + name: Build Backend + needs: build-frontend + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + repository: "Westwoodlabs/strichliste-backend" + ref: ${{ env.BRANCH }} + + - name: Build + uses: php-actions/composer@v6 + with: + php_version: "8.1" + dev: no + args: --optimize-autoloader + + - name: Display structure of files + run: ls -R + + - name: Cleanup + run: | + sudo rm -rf var/cache/* + + - name: Upload build artifacts + uses: actions/upload-artifact@v3 + with: + name: backend + + build-image: + name: Build and Push Docker Image + needs: build-backend + runs-on: ubuntu-latest + if: github.ref == 'refs/heads/wamp' + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Download Backend artifacts + uses: actions/download-artifact@v3 + with: + name: backend + path: ./build/ + + - name: Download Frontend artifacts + uses: actions/download-artifact@v3 + with: + name: frontend + path: ./build/public + + - name: Display structure of files + run: ls -R + + - name: Log in to the Container registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + # set latest tag for default branch + type=raw,value=latest,enable={{is_default_branch}} + + - name: Build and push Docker image + id: docker_build_and_push + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + platforms: linux/amd64,linux/arm/v7,linux/arm64 + + - name: Image digests + run: | + echo image digest: ${{ steps.docker_build_and_push.outputs.digest }} + + \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..414cc2c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,10 @@ +FROM php:8.1-apache + +RUN docker-php-ext-install pdo_mysql + +COPY ./build/ /var/www/html + +RUN chown -R www-data:www-data /var/www/html + +# configure apache +COPY ./src/apache.conf /etc/apache2/sites-available/000-default.conf \ No newline at end of file diff --git a/README.md b/README.md index 538c006..9c952c2 100644 --- a/README.md +++ b/README.md @@ -31,33 +31,24 @@ DATABASE_URL=mysql://strichliste:@db/strichliste Example docker-compose configuration: ```yml -version: "3.8" - services: - - web: - build: ./data/web + strichliste: + image: ghcr.io/westwoodlabs/strichliste:latest + restart: unless-stopped env_file: - settings.env networks: - - reverse-proxy - internal + port: + - 80:80 volumes: - - ./data/web/services.yaml:/var/www/html/config/services.yaml - - ./data/web/strichliste.yaml:/var/www/html/config/strichliste.yaml - - ./data/web/doctrine.yaml:/var/www/html/config/packages/doctrine.yaml - labels: - - "traefik.enable=true" - - "traefik.http.routers.strichliste.rule=Host(`myhostname.fqdn.local`)" - - "traefik.http.routers.strichliste.entryPoints=https" - - "traefik.http.routers.strichliste.tls=true" - - "traefik.http.services.strichliste.loadbalancer.server.scheme=http" - - "traefik.http.services.strichliste.loadbalancer.server.port=80" - restart: unless-stopped - depends_on: + - ./data/strichliste/strichliste.yaml:/var/www/html/config/strichliste.yaml + + depends_on: - db + db: - image: mariadb + image: mariadb:11.4 restart: unless-stopped env_file: - settings.env @@ -67,7 +58,7 @@ services: - internal telegram: - build: ./data/telegram + image: ghcr.io/westwoodlabs/strichliste-telegram:latest restart: unless-stopped volumes: - ./data/telegram/authorizedUsers.json:/usr/src/app/authorizedUsers.json @@ -76,8 +67,6 @@ services: - internal networks: - reverse-proxy: - external: true internal: external: false ``` diff --git a/data/web/strichliste.yaml b/data/strichliste/strichliste.yaml similarity index 100% rename from data/web/strichliste.yaml rename to data/strichliste/strichliste.yaml diff --git a/data/telegram/Dockerfile b/data/telegram/Dockerfile deleted file mode 100644 index 0260f75..0000000 --- a/data/telegram/Dockerfile +++ /dev/null @@ -1,23 +0,0 @@ -#download StrichlisteTelegramBridge with git clone -FROM alpine:3.8 as release - -RUN apk --no-cache add ca-certificates \ - && apk --no-cache add \ - git - -RUN mkdir /source - -WORKDIR /source - -RUN git clone --depth=1 https://github.com/Westwoodlabs/strichliste-telegram.git . - -# build StrichlisteTelegramBridge container -FROM python:3 - -COPY --from=release /source /usr/src/app - -WORKDIR /usr/src/app - -RUN pip install --no-cache-dir -r /usr/src/app/requirements.txt - -CMD [ "python", "./bot.py" ] \ No newline at end of file diff --git a/data/web/Dockerfile b/data/web/Dockerfile deleted file mode 100644 index 41e77e4..0000000 --- a/data/web/Dockerfile +++ /dev/null @@ -1,23 +0,0 @@ -FROM alpine:3.8 as release - -RUN apk --no-cache add ca-certificates \ - && apk --no-cache add \ - curl \ - tar - -RUN mkdir /source -WORKDIR /source -RUN curl -Lo strichliste.tar.gz https://github.com/strichliste/strichliste/releases/download/v1.7.1/strichliste.tar.gz -RUN tar -xf strichliste.tar.gz -RUN rm -r strichliste.tar.gz - -FROM php:7.3-apache - -RUN docker-php-ext-install pdo_mysql - -COPY --from=release /source /var/www/html - -RUN chown -R www-data:www-data /var/www/html - -# configure apache -COPY ./apache.conf /etc/apache2/sites-available/000-default.conf \ No newline at end of file diff --git a/data/web/doctrine.yaml b/data/web/doctrine.yaml deleted file mode 100644 index 26c31f9..0000000 --- a/data/web/doctrine.yaml +++ /dev/null @@ -1,33 +0,0 @@ -parameters: - # Adds a fallback DATABASE_URL if the env var is not set. - # This allows you to run cache:warmup even if your - # environment variables are not available yet. - # You should not need to change this value. - env(DATABASE_URL): '' - -doctrine: - dbal: - # configure these for your database server - driver: 'pdo_mysql' - server_version: '5.7' - charset: utf8mb4 - default_table_options: - charset: utf8mb4 - collate: utf8mb4_unicode_ci - - url: '%env(resolve:DATABASE_URL)%' - orm: - auto_generate_proxy_classes: '%kernel.debug%' - naming_strategy: doctrine.orm.naming_strategy.underscore - auto_mapping: true - dql: - datetime_functions: - date: App\Doctrine\Functions\Date - iif: App\Doctrine\Functions\Iif - mappings: - App: - is_bundle: false - type: annotation - dir: '%kernel.project_dir%/src/Entity' - prefix: 'App\Entity' - alias: App diff --git a/data/web/services.yaml b/data/web/services.yaml deleted file mode 100644 index e8e5dd0..0000000 --- a/data/web/services.yaml +++ /dev/null @@ -1,34 +0,0 @@ -# This file is the entry point to configure your own services. -# Files in the packages/ subdirectory configure your dependencies. - -imports: - - { resource: 'strichliste.yaml' } - -# Put parameters here that don't need to change on each machine where the app is deployed -# https://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration -parameters: - webroot: '%kernel.project_dir%/public' - -services: - # default configuration for services in *this* file - _defaults: - autowire: true # Automatically injects dependencies in your services. - autoconfigure: true # Automatically registers your services as commands, event subscribers, etc. - public: false # Allows optimizing the container by removing unused services; this also means - # fetching services directly from the container via $container->get() won't work. - # The best practice is to be explicit about your dependencies anyway. - - # makes classes in src/ available to be used as services - # this creates a service per class whose id is the fully-qualified class name - App\: - resource: '../src/*' - exclude: '../src/{DependencyInjection,Entity,Migrations,Tests,Kernel.php}' - - # controllers are imported separately to make sure services can be injected - # as action arguments even if you don't extend any base controller class - App\Controller\: - resource: '../src/Controller' - tags: ['controller.service_arguments'] - - # add more service definitions when explicit configuration is needed - # please note that last definitions always *replace* previous ones diff --git a/data/web/apache.conf b/src/apache.conf similarity index 100% rename from data/web/apache.conf rename to src/apache.conf