Browse Source

8-use_pod_without_volume_with_a_code

master 0.2.6
Ilya Fedorov 4 years ago
parent
commit
a1fa07ee98
  1. 11
      devops/docker/Dockerfile
  2. 4
      devops/docker/nginx/etc/nginx/conf.d/default.conf
  3. 17
      devops/docker/nginx/etc/nginx/nginx.conf
  4. 2
      devops/k8s/0_ConfigMap/.gitignore
  5. 57
      devops/k8s/0_ConfigMap/nginx-dev.yaml
  6. 4
      devops/k8s/1_Service/notification-provider-app-service-dev.yaml
  7. 42
      devops/k8s/2_Deployment/notification-provider.yaml
  8. 16
      docker-compose.yml

11
devops/docker/Dockerfile

@ -1,9 +1,12 @@
FROM php:8.0-fpm-alpine3.14 AS base
RUN apk update && apk upgrade && \
apk add --no-cache $PHPIZE_DEPS libzip-dev composer && \
apk add --no-cache $PHPIZE_DEPS libzip-dev nginx composer && \
docker-php-ext-install zip pcntl
RUN mkdir -p /app
WORKDIR /app
RUN mkdir -p /var/www/localhost
WORKDIR /var/www/localhost
COPY devops/docker/nginx/etc/nginx/nginx.conf /etc/nginx/nginx.conf
COPY devops/docker/nginx/etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf
CMD ["/bin/sh", "-c", "nginx; php-fpm"]
FROM base AS pre_test
@ -19,7 +22,7 @@ COPY devops/docker/php/xdebug.ini /usr/local/etc/php/conf.d/xdebug.ini
FROM pre_test AS test
COPY ./app .
COPY env/app/app.env-dist .env
RUN chown -R www-data:www-data /app/* && \
RUN chown -R www-data:www-data /var/www/localhost/* && \
composer install --no-progress --optimize-autoloader --no-interaction

4
devops/docker/nginx/etc/nginx/conf.d/default.conf

@ -1,7 +1,5 @@
server {
root /var/www/localhost/public;
error_log /var/log/nginx/localhost-error.log;
access_log /var/log/nginx/localhost-access.log;
location / {
try_files $uri /index.php$is_args$args;
@ -9,7 +7,7 @@ server {
location ~ \.php {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass notification-provider_app_1:9000;
fastcgi_pass 127.0.0.1:9000;
fastcgi_buffer_size 16k;
fastcgi_buffers 4 16k;
include fastcgi_params;

17
devops/docker/nginx/etc/nginx/nginx.conf

@ -0,0 +1,17 @@
worker_processes auto;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
keepalive_timeout 65;
include /etc/nginx/conf.d/default.conf;
}

2
devops/k8s/0_ConfigMap/.gitignore

@ -1 +1 @@
app-dev.yaml
notification-provider-app-configmap0-dev.yaml

57
devops/k8s/0_ConfigMap/nginx-dev.yaml

@ -1,57 +0,0 @@
---
apiVersion: v1
kind: ConfigMap
metadata:
name: notification-provider-nginx-configmap0-dev
namespace: default
labels:
tier: notification-provider
component: nginx
environment: dev
data:
default.conf: |
server {
root /var/www/localhost/public;
error_log /var/log/nginx/localhost-error.log;
access_log /var/log/nginx/localhost-access.log;
location / {
try_files $uri /index.php$is_args$args;
}
location ~ \.php {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass 127.0.0.1:9000;
fastcgi_buffer_size 16k;
fastcgi_buffers 4 16k;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $document_root;
internal;
}
location ~ \.php$ {
return 404;
}
}
nginx.conf: |
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/default.conf;
}
...

4
devops/k8s/1_Service/nginx.yaml → devops/k8s/1_Service/notification-provider-app-service-dev.yaml

@ -2,11 +2,11 @@
apiVersion: v1
kind: Service
metadata:
name: notification-provider-nginx-service-dev
name: notification-provider-app-service-dev
namespace: default
labels:
tier: notification-provider
component: nginx
component: app
environment: dev
spec:
selector:

42
devops/k8s/2_Deployment/notification-provider.yaml

@ -25,43 +25,13 @@ spec:
tier: notification-provider
spec:
volumes:
- name: shared-files
emptyDir: { }
- name: notification-provider-app-configmap0-dev
configMap:
defaultMode: 0664
name: notification-provider-app-configmap0-dev
- name: notification-provider-nginx-configmap0-dev
configMap:
defaultMode: 0664
name: notification-provider-nginx-configmap0-dev
containers:
- name: php
image: gitlab-registry.fedy95.com:5002/dev/notification-provider:latest
resources:
requests:
cpu: "125m"
memory: "64Mi"
limits:
cpu: "250m"
memory: "128Mi"
volumeMounts:
- name: shared-files
mountPath: /var/www/localhost
- name: notification-provider-app-configmap0-dev
mountPath: /var/www/localhost/.env
subPath: .env
lifecycle:
postStart:
exec:
command:
- "/bin/sh"
- "-c"
- >
cp -rp /app/* /var/www/localhost
- name: nginx
image: nginx:1.21-alpine
- name: app
image: gitlab-registry.fedy95.com:5002/dev/notification-provider:test
resources:
requests:
cpu: "125m"
@ -70,17 +40,9 @@ spec:
cpu: "250m"
memory: "128Mi"
volumeMounts:
- name: shared-files
mountPath: /var/www/localhost
- name: notification-provider-app-configmap0-dev
mountPath: /var/www/localhost/.env
subPath: .env
- name: notification-provider-nginx-configmap0-dev
mountPath: /etc/nginx/nginx.conf
subPath: nginx.conf
- name: notification-provider-nginx-configmap0-dev
mountPath: /etc/nginx/conf.d/default.conf
subPath: default.conf
restartPolicy: Always
imagePullSecrets:
- name: gitlab-docker

16
docker-compose.yml

@ -21,22 +21,6 @@ services:
volumes:
- ${HOME}/.composer:${HOME}/.composer
- ./app:/var/www/localhost
expose:
- "9000"
networks:
- monitoring_monitor-net
nginx:
image: nginx:1.21-alpine
container_name: notification-provider_nginx_1
hostname: notification-provider_nginx_1
restart: always
depends_on:
- app
volumes:
- ./app:/var/www/localhost
- ./devops/docker/nginx/etc/nginx/conf.d/default.conf:/etc/nginx/conf.d/default.conf
ports:
- "8054:80"
networks:

Loading…
Cancel
Save