Skip to content

Commit

Permalink
Merge for v1.0.1 (#4)
Browse files Browse the repository at this point in the history
* Create LICENSE

* added dockerfile

* added gitginore

* removed node-yarn from scripts

* added start-container

* fixed user and group add

* updated readme, removed unnecessary deps

* add deployer to sudoers

* adding wheel to deployer group

* adding wheel to deployer group

* adding sudo

* adding sudo

* adding deployer to wheel

* adding deployer to wheel

* adding deployer to wheel

* adding deployer to wheel

* adding deployer to wheel

* adding deployer to wheel

* adding deployer to wheel

* adding deployer to wheel

* added exif to the php extensions

* Proofread (#1)

✍️   Fixed some typos

* updated readme.md to migrate to laramatics/container

* Updated readme for cron jobs

* Renamed cron settings and executable file

* changed scripts path from local to global

* Changed nginx-php supervisor configuration name.

* Added start-worker script

* Added start-worker script to Dockerfile

* we won't cleanup install-php-extensions for CI to be able to add more extensions

* Update README.md

Added FAQ section

* Updated PHP to 8.2.1

Co-authored-by: A.Ansari <[email protected]>
Co-authored-by: root <[email protected]>
  • Loading branch information
3 people authored Jan 16, 2023
1 parent 735f521 commit 59b5cc1
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 6 deletions.
15 changes: 11 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG PHP_VERSION=8.1.1
ARG PHP_VERSION=8.2.1
FROM php:${PHP_VERSION}-fpm-alpine
LABEL maintainer="Pezhvak <[email protected]>"
# NOTE: ARGs before FROM cannot be accessed during build time (https://docs.docker.com/engine/reference/builder/#understand-how-arg-and-from-interact)
Expand All @@ -12,8 +12,12 @@ RUN chmod +x /usr/local/bin/install-php-extensions
# Copy Scripts
COPY scripts /tmp
RUN chmod +x /tmp/*.sh
COPY scripts/start-container /usr/local/bin
RUN chmod +x /usr/local/bin/start-container
COPY scripts/start-container /usr/bin
COPY scripts/start-cron /usr/bin
COPY scripts/start-worker /usr/bin
RUN chmod +x /usr/bin/start-container
RUN chmod +x /usr/bin/start-cron
RUN chmod +x /usr/bin/start-worker

# Install
RUN ash /tmp/install-packages.sh
Expand All @@ -32,10 +36,13 @@ RUN rm -rf /tmp/*
EXPOSE 80

# Services supervisor config
COPY ./configs/supervisord.conf /etc/supervisor.d/supervisord.conf
COPY ./configs/supervisord.conf /etc/supervisor.d/php-nginx.conf

# Override nginx's default config
COPY ./configs/nginx.conf /etc/nginx/http.d/default.conf

# Set crontab configurations
COPY ./configs/crontab.txt /etc/crontabs/root

CMD ["/usr/bin/supervisord", "-n","-c", "/etc/supervisord.conf"]
ENTRYPOINT ["start-container"]
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ Although folder structure is self-explanatory, description is below:
```
.
├── configs
│   ├── crontab.txt # crontab configuration file.
│   ├── nginx.conf # default nginx configuration file.
│   └── supervisord.conf # php/nginx supervisor configuration file.
├── Dockerfile
Expand All @@ -72,6 +73,7 @@ Although folder structure is self-explanatory, description is below:
│   ├── install-packages.sh # OS packages will be installed by this file.
│   ├── install-php.sh # PHP extensions and installation.
│   └── start-container # Container entry-point script.
│   └── start-cron # Running container with cron job role.
└── tests
└── goss.yaml # See "testing" section.
```
Expand Down Expand Up @@ -136,3 +138,9 @@ modifying source files and building your own image, run:
```shell
GOSS_FILES_PATH=tests dgoss run -it <image_name> /bin/ash -l
```

### FAQ

*Q:* How can i change php-fpm port?

*A:* Sometimes you need to change default php-fpm port which is 9000 in order to serve multiple containers under same pod. to do that modify the port in `/usr/local/etc/php-fpm.d/zz-docker.conf`.
1 change: 1 addition & 0 deletions configs/crontab.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* * * * * cd /var/www/html && php artisan schedule:run >> /dev/stdout 2>&1
5 changes: 3 additions & 2 deletions scripts/cleanup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@

# Remove Build Dependencies
apk del -f .build-deps
rm /usr/local/bin/install-php-extensions
rm /usr/local/bin/docker-php-*
# we need these for adding extra extensions in CI
# rm /usr/local/bin/install-php-extensions
# rm /usr/local/bin/docker-php-*
2 changes: 2 additions & 0 deletions scripts/start-cron
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/env ash
crond -f
7 changes: 7 additions & 0 deletions scripts/start-worker
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env ash

if [ $# -gt 0 ]; then
exec exec /usr/local/bin/php /var/www/html/artisan queue:work "$@"
else
exec /usr/local/bin/php /var/www/html/artisan queue:work --timeout=3600 --tries=3 --no-interaction
fi

0 comments on commit 59b5cc1

Please sign in to comment.