0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Picoをdockerで動かす

Posted at

本記事の目的

PicoというMarkdownで記事を書くCMSをdockerで利用する。
構成は以下です。

  • PHP(php:8.0-fpm)
  • Nginx

ソース

                │  ├─filters

ディレクトリ構成

├─nginx
│  ├─Dockerfile
│  └─conf/nginx.conf
├─php
│  ├─Dockerfile
│  └─php.ini
└─src

docker-compose.yml

docker-compose.yml
version: '3'
services:
  php:
    build:
      context: ./php
      args:
        TZ: $TZ
    volumes:
      - ./src:/var/www/html/
      - ./php/php.ini:/usr/local/etc/php/conf.d/php.ini

  nginx:
    build:
      context: ./nginx
      args:
        TZ: $TZ
    ports:
      - "80:80"
    volumes:
      - ./nginx/conf:/etc/nginx/conf.d
      - ./src:/var/www/html/
    depends_on:
      - php

PHP

php/Dockerfile
FROM php:8.0-fpm
ENV DEBIAN_FRONTEND noninteractive

RUN apt-get update && apt-get install -y \
        libfreetype6-dev \
        libjpeg62-turbo-dev \
        libpng-dev \
        apt-utils \
        zip \
    && docker-php-ext-configure gd --with-freetype --with-jpeg \
    && docker-php-ext-install -j$(nproc) gd

# Timezone
ARG TZ
RUN apt-get install -y tzdata && \
    cp /usr/share/zoneinfo/Asia/Tokyo /etc/localtime && \
    echo ${TZ} > /etc/timezone

# Composer
COPY --from=composer /usr/bin/composer /usr/bin/composer

# coofiguration
COPY php.ini /usr/local/etc/php/
php/php.ini
date.timezone = "Asia/Tokyo"

Nginx

nginx/Dockerfile
FROM nginx:1.19.6

ADD conf /etc/nginx/conf.d

ARG TZ
ENV TZ ${TZ}
RUN apt-get install -y tzdata && \
    echo "${TZ}" > /etc/timezone && \
    dpkg-reconfigure -f noninteractive tzdata

RUN ln -sf /dev/stdout /var/log/nginx/access.log \
	&& ln -sf /dev/stdout /var/log/nginx/error.log
nginx/conf/nginx.conf
server {
	listen 80;

	server_name _;
	root /var/www/html/pico;

	index index.php index.html;

	location ~ ^/((config|content|vendor|composer\.(json|lock|phar))(/|$)|(.+/)?\.(?!well-known(/|$))) {
		try_files /index.php$is_args$args =404;
	}

	location ~ \.php$ {
		try_files $uri =404;

		fastcgi_pass php:9000;
		fastcgi_index index.php;
		fastcgi_param SCRIPT_FILENAME  $document_root$fastcgi_script_name;
		include fastcgi_params;

		# Let Pico know about available URL rewriting
		fastcgi_param PICO_URL_REWRITING 1;
	}

	location / {
		try_files $uri $uri/ /index.php$is_args$args;
	}
}

リポジトリ

Githubに使ったリポジトリは残しておきます。

ちなみにだけどPicoを使おうと思いましたがGravの方が優れていたいので今回はPicoで運用しませんでした(テヘペロ)

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?