Skip to content

Add docker nginx & php-fpm - #37

Draft
kenjis wants to merge 5 commits into
codeigniter4:developfrom
kenjis:add-docker-nginx-php-fpm
Draft

Add docker nginx & php-fpm#37
kenjis wants to merge 5 commits into
codeigniter4:developfrom
kenjis:add-docker-nginx-php-fpm

Conversation

@kenjis

Copy link
Copy Markdown
Member
  • add Nginx 1.23
  • add PHP-FPM 8.1

@kenjis
kenjis marked this pull request as draft July 23, 2022 07:56

@MGatnerMGatner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you mean to move these back into Template/? If so please justify.

@kenjis

Copy link
Copy Markdown
MemberAuthor

You need to copy files to use Nginx and PHP.

Copy docker/ folder and docker-compose.yaml to your CodeIgniter4 project root.
https://github.com/codeigniter4/devkit/pull/37/files#diff-079c8a90be414928ae24510a296a33243d0c17372a82a91876d033137b089544R14

@MGatner

Copy link
Copy Markdown
Member

Got it! I rarely use Docker but let me know when this is ready for review and I will take it for a spin. I should be a good Guinea pig for the instructions given my noobiness

@jozefrebjak

Copy link
Copy Markdown

@kenjis I'm using docker in my development and here is the my setup.

I have folder docker with development and production folders, so I suggest to move development Dockerfile to docker/development and have an opportunity to add production folder if it's needed in future for users.

I started also to build Dockerfile with nginx & php-fpm separated, but there is no customisable options, if we want to customise something during the development it's a pain.

So I started my journey to find suitable image with php-fpm & nginx in one image with customisable options and in the end I found it. Here is the link to image:
https://github.com/tiredofit/docker-nginx-php-fpm

It works perfectly for development and even for production.

My Dockerfile for development looks now like:

FROM tiredofit/nginx-php-fpm:8.0-alpine_3.16
ENV STAGE DEVELOPMENT
ENV TIMEZONE Europe/Bratislava
ENV NGINX_WEBROOT /app/public
ENV PHP_MEMORY_LIMIT 1G
ENV PHP_ENABLE_PDO_SQLITE TRUE
ENV PHP_ENABLE_REDIS TRUE
WORKDIR /app
COPY . .

I'm enabling ENV variables directly in Dockerfile and I can overwrite them or add another in docker-compose if needed.

My docker-compose looks like:

version: "3.7"services:
app:
build:
context: .dockerfile: docker/development/Dockerfileports:
- 8080:80volumes:
- .:/appdepends_on:
- redis
- mariadbnetworks:
- codeigniter4redis:
image: redis:alpineports:
- 6379:6379volumes:
- redis:/datanetworks:
- codeigniter4mariadb:
image: mariadb:latestports:
- 3306:3306volumes:
- ./initdb:/docker-entrypoint-initdb.d
- mariadb:/var/lib/mysqlenvironment:
MYSQL_ROOT_PASSWORD: rootMYSQL_DATABASE: gponcontrolMYSQL_USER: gponcontrolMYSQL_PASSWORD: gponcontrolnetworks:
- codeigniter4phpmyadmin:
image: phpmyadmin/phpmyadmin:latestenvironment:
PMA_HOST: mariadbPMA_PORT: 3306ports:
- 8888:80volumes:
- phpmyadmin:/sessionsdepends_on:
- mariadbnetworks:
- codeigniter4networks:
codeigniter4:
volumes:
redis:
mariadb:
phpmyadmin:

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@kenjis@MGatner@jozefrebjak