Skip to content
forked from psliwa/PHPPdf

Commit

Permalink
feat(FIAP-197): use alpine and update composer
Browse files Browse the repository at this point in the history
  • Loading branch information
haeber committed Jun 5, 2023
1 parent d501c4b commit cd8fbe4
Show file tree
Hide file tree
Showing 11 changed files with 113 additions and 87 deletions.
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@
"email": "peter.pl7@gmail.com"
}
],
"repositories": [
{"type": "vcs", "no-api": true, "url": "git@github.com:jobcloud/zendpdf.git"}
],
"require": {
"ext-mbstring": "*",
"jobcloud/zendpdf": "^1.0.0"
"jobcloud/zendpdf": "^2.0.3"
},
"require-dev": {
"imagine/imagine": ">=0.2.0,<0.6.0",
"phpunit/phpunit": "^9.6.7"
"phpunit/phpunit": "^8.5.33"
},
"prefer-stable": true,
"minimum-stability": "dev",
"repositories": [
{"type": "vcs", "no-api": true, "url": "git@github.com:jobcloud/ZendPdf.git"}
],
"suggest": {
"imagine/imagine": "If you want to use image generating (required version: >=v0.2.6)"
},
Expand Down
3 changes: 3 additions & 0 deletions docker/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
COMPOSE_PROJECT_NAME=jobcloud-phppdf
XDEBUG_REMOTE_HOST=localhost
#XDEBUG_REMOTE_HOST=docker.for.mac.localhost
47 changes: 0 additions & 47 deletions docker/Dockerfile

This file was deleted.

25 changes: 25 additions & 0 deletions docker/docker-compose.dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
version: '3.9'
services:
php:
container_name: jobcloud-phppdf-php
hostname: jobcloud-phppdf-php
build:
dockerfile: php/Dockerfile
context: ./
args:
USER_ID: ${USER_ID}
ports:
- '8080:80'
tty: true
volumes:
- ../:/var/www/html
- ~/.bash_aliases:/home/www-data/.bash_aliases:rw
- ~/.bash_history:/home/www-data/.bash_history:rw
secrets:
- ssh_host_key
environment:
XDEBUG_CONFIG: remote_host=${XDEBUG_REMOTE_HOST}
PHP_IDE_CONFIG: serverName=php
secrets:
ssh_host_key:
file: ~/.ssh/id_rsa
12 changes: 0 additions & 12 deletions docker/docker-compose.yml

This file was deleted.

37 changes: 37 additions & 0 deletions docker/php/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
FROM php:8.1-alpine3.18

ARG USER_ID

# PHP: Copy configuration files & remove dist files
RUN mkdir /phpIni
COPY php/files/bin/ /usr/local/bin/

# SYS: Install required packages
RUN apk --no-cache upgrade && \
apk --no-cache add bash git sudo openssh autoconf gcc g++ make gettext sudo shadow

RUN if [ -n "$USER_ID" ] && [ "$USER_ID" -lt 60001 ]; then \
usermod -u ${USER_ID} -o www-data; \
fi

# USER: set /bin/bash and allow www-data to become root
RUN usermod -s /bin/bash www-data && \
echo 'www-data ALL=(ALL) NOPASSWD: ALL' > '/etc/sudoers.d/www-data'

# USER: copy home
COPY --chown=www-data:www-data php/files/user-home /home/www-data

# USER: add ssh key and fix permission of the ssh directory
RUN ln -s /run/secrets/ssh_host_key /home/www-data/.ssh/id_rsa && \
chmod 700 /home/www-data/.ssh && \
chmod 400 /home/www-data/.ssh/config

# PHP: Install php extensions
RUN pecl channel-update pecl.php.net

# COMPOSER: install binary
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer

USER www-data

WORKDIR /var/www/html
12 changes: 12 additions & 0 deletions docker/php/files/bin/php-ext-disable
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

if [ $# -eq 0 ]
then
echo "Please pass a php module name"
exit
fi

for phpmod in "$@"
do
rm -f /usr/local/etc/php/conf.d/*$phpmod*.ini
done
20 changes: 20 additions & 0 deletions docker/php/files/bin/php-ext-enable
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

if [[ ${#} -eq 0 ]] ; then
echo -e "\\nPHP module name required!\\n"
exit 1
fi

for phpmod in "${@}" ; do

files=($(find /phpIni -type f -iname "*${phpmod}*.ini" -exec ls -1 '{}' +))

for i in "${files[@]}" ; do
ln -s "${i}" /usr/local/etc/php/conf.d
done

if [[ ${#files[@]} -eq 0 ]] ; then
docker-php-ext-enable "${phpmod}"
fi

done
7 changes: 7 additions & 0 deletions docker/php/files/user-home/.bashrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
alias cls='printf "\033c"'

export PS1='\[\e[1;32m\]\h\[\e[0m\] \[\e[1;37m\]\w\[\e[0m\] \[\e[1;32m\]\u\[\e[0m\] \[\e[1;37m\]\$\[\e[0m\] '

if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
4 changes: 4 additions & 0 deletions docker/php/files/user-home/.ssh/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Host *
StrictHostKeyChecking no
UserKnownHostsFile /dev/null
IdentityFile /run/secrets/ssh_host_key
23 changes: 0 additions & 23 deletions test.php

This file was deleted.

0 comments on commit cd8fbe4

Please sign in to comment.