diff --git a/.github/workflows/build-push.yml b/.github/workflows/build-push.yml index 2ea3558..470ede1 100644 --- a/.github/workflows/build-push.yml +++ b/.github/workflows/build-push.yml @@ -39,7 +39,7 @@ jobs: name: Build and push uses: docker/build-push-action@v5 with: - context: ./bin/api-ws/ + context: ./ platforms: linux/amd64,linux/arm/v7,linux/arm64 push: true tags: ${{ env.REGISTRY_IMAGE_TAG }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a3357a1..a266384 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,6 +1,28 @@ name: CI on: [push] jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Log in to the Container registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Build and push + uses: docker/build-push-action@v5 + with: + context: ./ + platforms: linux/amd64,linux/arm64 + push: false + # tags: ghcr.io/edgebox-iot/api:${{ github.ref_name }},ghcr.io/edgebox-iot/api:latest test: runs-on: ubuntu-latest steps: diff --git a/CHANGELOG.md b/CHANGELOG.md index 3c24825..98e623d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,8 @@ ## [1.3.1] - Unreleased * Fixed linting and code style issues across the project +* Added action to build docker image on push to Pull Requests +* Optimized the Dockerfile build to include the app and dependencies in different layers ## [1.3.0] - 05-12-2020 diff --git a/bin/api-ws/Dockerfile b/Dockerfile similarity index 62% rename from bin/api-ws/Dockerfile rename to Dockerfile index b963a11..26a2b62 100755 --- a/bin/api-ws/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM php:8.1-apache-buster +FROM php:8.1-apache as php-base ARG DEBIAN_FRONTEND=noninteractive @@ -22,24 +22,19 @@ RUN apt-get -y update --fix-missing \ libfreetype6-dev \ libjpeg62-turbo-dev \ libpng-dev \ - && rm -rf /var/lib/apt/lists/* - - # Additional packages that might be removed - # libmagickwand-dev \ - -# Install PHP Extensions -RUN docker-php-ext-install \ - pdo_sqlite \ - mysqli \ - curl \ - zip \ - intl \ - mbstring \ - gettext \ - exif \ - gd - -# Install additional PHP Extensions + && rm -rf /var/lib/apt/lists/* \ + && docker-php-ext-install \ + pdo_sqlite \ + mysqli \ + curl \ + zip \ + intl \ + mbstring \ + gettext \ + exif \ + gd + +# To Install additional PHP Extensions you can also use pecl # RUN pecl install xdebug-3.2.0 \ # && docker-php-ext-enable xdebug \ # && pecl install redis-5.3.3 \ @@ -47,11 +42,15 @@ RUN docker-php-ext-install \ # && pecl install imagick \ # && docker-php-ext-enable imagick -# Enable apache modules -# RUN a2enmod rewrite headers +FROM php-base as final -# Layering Composer binary COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer +COPY ./src/composer.json ./src/composer.lock ./ + +COPY ./src /var/www/html + +ENV APP_ENV=prod + +RUN composer install --no-dev --optimize-autoloader -# Cleanup -RUN rm -rf /usr/src/* +RUN rm -rf /usr/src/* \ No newline at end of file diff --git a/README.md b/README.md index 8c4755c..955da99 100755 --- a/README.md +++ b/README.md @@ -143,7 +143,7 @@ By default following extensions are installed. * xmlrpc * gd -> If you want to install more extensions, just update `./bin/api-ws/Dockerfile`. You can also generate a PR and it will be merged if it seems good for general purpose. +> If you want to install more extensions, just update `./Dockerfile`. You can also generate a PR and it will be merged if it seems good for general purpose. > You have to rebuild the docker image by running `docker-compose build` and restart the docker containers. ## phpMyAdmin diff --git a/docker-compose.yml b/docker-compose.yml index 06aeb79..8fdaf07 100755 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,7 +3,7 @@ version: "3" services: api-ws: build: - context: ./bin/api-ws + context: ./ restart: 'always' ports: - "${HOST_MACHINE_UNSECURE_HOST_PORT}:80" diff --git a/edgebox-compose.yml b/edgebox-compose.yml index af93ec8..f75fb31 100644 --- a/edgebox-compose.yml +++ b/edgebox-compose.yml @@ -6,7 +6,7 @@ services: api-ws: # image: ghcr.io/edgebox-iot/api:latest build: - context: ../api/bin/api-ws + context: ./ container_name: '${COMPOSE_PROJECT_NAME}-api-ws' restart: always volumes: