Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add source code and composer dependencies to image build #79

Merged
merged 6 commits into from
Dec 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
22 changes: 22 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
47 changes: 23 additions & 24 deletions bin/api-ws/Dockerfile → Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM php:8.1-apache-buster
FROM php:8.1-apache as php-base

ARG DEBIAN_FRONTEND=noninteractive

Expand All @@ -22,36 +22,35 @@ 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 \
# && docker-php-ext-enable redis \
# && 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/*
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: "3"
services:
api-ws:
build:
context: ./bin/api-ws
context: ./
restart: 'always'
ports:
- "${HOST_MACHINE_UNSECURE_HOST_PORT}:80"
Expand Down
2 changes: 1 addition & 1 deletion edgebox-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Loading