Skip to content

Commit

Permalink
CI/CD adjustments and repository reorganization
Browse files Browse the repository at this point in the history
  • Loading branch information
fabioassuncao committed Jun 27, 2024
1 parent 8ba24f7 commit 24d37b6
Show file tree
Hide file tree
Showing 8 changed files with 107 additions and 134 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/docker-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,5 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: echo "${GITHUB_TOKEN}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin

- name: Build and Push
run: bash build.sh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push to registry
run: make release-all
27 changes: 27 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
IMAGE?=ghcr.io/fabioassuncao/php
VERSION?=8.3
DOCKER_RUN:=docker run --rm ${IMAGE}:${VERSION}
DEFAULT_ARCHS?=linux/amd64

help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "⚡ \033[34m%-30s\033[0m %s\n", $$1, $$2}'

build: ## Build docker image
docker buildx build --load --platform $(DEFAULT_ARCHS) -t $(IMAGE):${VERSION} -f php/${VERSION}/Dockerfile php/${VERSION}/

release: ### Build and push image to Registry
echo "Releasing: ${IMAGE}${VERSION}"
docker buildx build --push --platform $(DEFAULT_ARCHS) -t $(IMAGE):${VERSION} -f php/${VERSION}/Dockerfile php/${VERSION}/

release-all: ### Build all PHP version and push image to Registry
echo "Releasing all PHP version"
VERSION=8.3 make release

test: ### Test image
$(DOCKER_RUN) php -v
$(DOCKER_RUN) sh -c "php -v | grep ${VERSION}"
$(DOCKER_RUN) sh -c "php -v | grep OPcache"
$(DOCKER_RUN) sh -c "nginx -t"

test-all: ### Test all image
VERSION=8.3 make build test
76 changes: 76 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,82 @@ Simple docker image for PHP/Laravel development.
- Multi-platform, supporting AMD4, ARMv6, ARMv7, ARM64
- Very small Docker image size

### How to use

Build image

```shell
VERSION=8.3 make build
```

Release image

```shell
VERSION=8.3 make release
```

How to customize image name

```shell
VERSION=8.3 IMAGE=ghcr.io/fabioassuncao/php make build
```

Test image by PHP version

```shell
VERSION=8.3 make test
```

Test all image

```shell
make test-all
```

Mount your code to be served with container

```shell
docker run --name=app -v /path/to/project:/var/www/html -p 8000:8000 ghcr.io/fabioassuncao/php:8.3
```

Using docker-compose

```
x-function: &common_setup
image: ghcr.io/fabioassuncao/php:8.3
restart: always
environment:
CONTAINER_ROLE: app
CONTAINER_MODE: automatic
networks:
- laravel
env_file:
- .env
volumes:
- .:/var/www/html
services:
app:
<<: *common_setup
ports:
- '8000:8000'
horizon:
<<: *common_setup
environment:
CONTAINER_ROLE: horizon
scheduler:
<<: *common_setup
environment:
CONTAINER_ROLE: scheduler
networks:
laravel:
driver: bridge
```

### PHP version support
- [x] PHP 8.3

Expand Down
121 changes: 0 additions & 121 deletions build.sh

This file was deleted.

9 changes: 2 additions & 7 deletions php/8.3-alpine/Dockerfile → php/8.3/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,14 @@ RUN pecl install excimer && echo "extension=excimer.so" > /etc/php83/conf.d/50_e
RUN apk del gcc make autoconf musl-dev php83-dev

# PHP Configuration
COPY ./docker/php/conf.d/custom.ini /etc/php83/conf.d/custom.ini
COPY ./conf.d/custom.ini /etc/php83/conf.d/custom.ini

# Install Composer
COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer

WORKDIR /var/www/html

# Building process
COPY . /var/www/html
RUN composer install && \
chown -R nobody:nobody /var/www/html/storage

COPY ./docker/entrypoint.sh /usr/local/bin/entrypoint
COPY ./entrypoint.sh /usr/local/bin/entrypoint
RUN chmod +x /usr/local/bin/entrypoint

EXPOSE 8000
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 0 additions & 2 deletions php/buildvars

This file was deleted.

0 comments on commit 24d37b6

Please sign in to comment.