Skip to content

Commit

Permalink
Merge pull request #31 from jkaninda/develop
Browse files Browse the repository at this point in the history
chore: upgrade Node version from 17 to 20
  • Loading branch information
jkaninda authored Sep 18, 2024
2 parents 6c7be22 + 18658c7 commit 193e19d
Show file tree
Hide file tree
Showing 5 changed files with 160 additions and 14 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Integration Test
name: Test
on:
push:
jobs:
Expand All @@ -14,7 +14,7 @@ jobs:
- name: Run docker-compose
run:
cp ./tests/compose.yaml compose.yaml &&
docker-compose -f "compose.yaml" up -d
docker compose -f "compose.yaml" up -d
- name: Create script.js for K6 test
run: |
touch script.js && cat > script.js <<EOF
Expand Down
39 changes: 29 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,28 +41,47 @@
## Simple docker-compose usage:

```yml
version: '3'
services:
app:
image: jkaninda/nginx-php-fpm:8.3
container_name: my-app
container_name: app
restart: unless-stopped
user: www-data # Optional - for production usage
volumes:
#Project root
- ./:/var/www/html
- ./src:/var/www/html
ports:
- "80:80"
networks:
- default #if you're using networks between containers

```
## Laravel `artisan` command usage:
### CLI
## Docker:
### Run
```sh
docker-compose exec app bash

docker compose up -d
```
### Create Laravel project
```sh
docker compose exec app composer create-project --prefer-dist laravel/laravel .
```
### Artisan generate key
```sh
docker compose exec app php artisan key:generate
```
### Storage link
```sh
docker compose exec app php artisan storage:link
```
### Fix permissions
```sh
docker compose exec app chmod -R 777 storage bootstrap/cache
```
### Laravel migration
```sh
docker compose exec app php artisan migrate
```
###
```sh
docker exec -it app bash

Expand All @@ -75,7 +94,7 @@ version: '3'
services:
app:
image: jkaninda/nginx-php-fpm
container_name: nginx-fpm
container_name: app
restart: unless-stopped
ports:
- "80:80"
Expand All @@ -100,7 +119,7 @@ Default web root:

## Docker run
```sh
docker-compose up -d
docker compose up -d

```
## Build from base
Expand Down Expand Up @@ -153,7 +172,7 @@ stdout_logfile=/var/www/html/storage/logs/kafka.log

### Storage permision issue
```sh
docker-compose exec php-fpm /bin/bash
docker compose exec php-fpm /bin/bash
```
```sh
chown -R www-data:www-data /var/www/html/
Expand Down
2 changes: 1 addition & 1 deletion src/docker/8.2/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ ENV DOCUMENT_ROOT=${WORKDIR}
ENV LARAVEL_PROCS_NUMBER=1
ENV DOMAIN=_
ENV CLIENT_MAX_BODY_SIZE=15M
ENV NODE_VERSION=17.x
ENV NODE_VERSION=20.x
ARG GROUP_ID=1000
ARG USER_ID=1000
ENV USER_NAME=www-data
Expand Down
2 changes: 1 addition & 1 deletion src/docker/8.3/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ ENV DOCUMENT_ROOT=${WORKDIR}
ENV LARAVEL_PROCS_NUMBER=1
ENV DOMAIN=_
ENV CLIENT_MAX_BODY_SIZE=15M
ENV NODE_VERSION=17.x
ENV NODE_VERSION=20.x
ARG GROUP_ID=1000
ARG USER_ID=1000
ENV USER_NAME=www-data
Expand Down
127 changes: 127 additions & 0 deletions src/docker/8.4/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
FROM php:8.4-rc-fpm
ARG WORKDIR=/var/www/html
ENV DOCUMENT_ROOT=${WORKDIR}
ENV LARAVEL_PROCS_NUMBER=1
ENV DOMAIN=_
ENV CLIENT_MAX_BODY_SIZE=15M
ENV NODE_VERSION=20.x
ARG GROUP_ID=1000
ARG USER_ID=1000
ENV USER_NAME=www-data
ARG GROUP_NAME=www-data
# Install system dependencies
RUN apt-get update && apt-get install -y \
git \
curl \
libfreetype6-dev \
libjpeg62-turbo-dev \
libmemcached-dev \
libzip-dev \
libpng-dev \
libonig-dev \
libxml2-dev \
librdkafka-dev \
libpq-dev \
openssh-server \
zip \
unzip \
supervisor \
sqlite3 \
nano \
cron

RUN curl -fsSL https://deb.nodesource.com/setup_${NODE_VERSION} | bash -
# Install Node
RUN apt-get install -y nodejs
# Install nginx
RUN apt-get update && apt-get install -y nginx

# Clear cache
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
# Install Kafka
RUN git clone https://github.com/arnaud-lb/php-rdkafka.git\
&& cd php-rdkafka \
&& phpize \
&& ./configure \
&& make all -j 5 \
&& make install

# Install Rdkafka and enable it
RUN docker-php-ext-enable rdkafka \
&& cd .. \
&& rm -rf /php-rdkafka

# Install PHP extensions zip, mbstring, exif, bcmath, intl
RUN docker-php-ext-configure gd --with-freetype --with-jpeg
RUN docker-php-ext-install zip mbstring exif pcntl bcmath -j$(nproc) gd intl

# Install Redis and enable it
RUN pecl install redis && docker-php-ext-enable redis



# Install the php memcached extension
RUN pecl install memcached && docker-php-ext-enable memcached

# Install the PHP pdo_mysql extention
RUN docker-php-ext-install pdo_mysql

# Install the PHP pdo_pgsql extention
RUN docker-php-ext-install pdo_pgsql

# Install PHP Opcache extention
RUN docker-php-ext-install opcache

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

# Set working directory
WORKDIR $WORKDIR

RUN rm -Rf /var/www/* && \
mkdir -p /var/www/html

ADD src/index.php $WORKDIR/index.php
ADD src/php.ini $PHP_INI_DIR/conf.d/
ADD src/opcache.ini $PHP_INI_DIR/conf.d/
ADD src/supervisor/supervisord.conf /etc/supervisor/supervisord.conf

COPY src/entrypoint.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/entrypoint.sh
RUN ln -s /usr/local/bin/entrypoint.sh /


RUN rm -rf /etc/nginx/conf.d/default.conf
RUN rm -rf /etc/nginx/sites-enabled/default
RUN rm -rf /etc/nginx/sites-available/default

RUN rm -rf /etc/nginx/nginx.conf

COPY src/nginx.conf /etc/nginx/nginx.conf
COPY src/default.conf /etc/nginx/conf.d/

RUN usermod -u ${USER_ID} ${USER_NAME}
RUN groupmod -g ${USER_ID} ${GROUP_NAME}

RUN mkdir -p /var/log/supervisor
RUN mkdir -p /var/log/nginx
RUN mkdir -p /var/cache/nginx

RUN chown -R ${USER_NAME}:${GROUP_NAME} /var/www && \
chown -R ${USER_NAME}:${GROUP_NAME} /var/log/ && \
chown -R ${USER_NAME}:${GROUP_NAME} /etc/supervisor/conf.d/ && \
chown -R ${USER_NAME}:${GROUP_NAME} $PHP_INI_DIR/conf.d/ && \
touch /var/run/nginx.pid && \
chown -R $USER_NAME:$USER_NAME /var/cache/nginx && \
chown -R $USER_NAME:$USER_NAME /var/lib/nginx/ && \
chown -R $USER_NAME:$USER_NAME /var/run/nginx.pid && \
chown -R $USER_NAME:$USER_NAME /var/log/supervisor && \
chown -R $USER_NAME:$USER_NAME /etc/nginx/nginx.conf && \
chown -R $USER_NAME:$USER_NAME /etc/nginx/conf.d/ && \
chown -R ${USER_NAME}:${GROUP_NAME} /tmp


#USER ${USER_NAME}
EXPOSE 80
ENTRYPOINT ["entrypoint.sh"]

0 comments on commit 193e19d

Please sign in to comment.