Browse Source

测试构建

kely 1 year ago
parent
commit
ade23b6590
5 changed files with 177 additions and 9 deletions
  1. 0 0
      Dockerfilecopy
  2. 60 0
      app.dockerfile
  3. 71 9
      docker-compose.yml
  4. 11 0
      docker-composecopy.yml
  5. 35 0
      web.dockerfile

+ 0 - 0
Dockerfile → Dockerfilecopy


+ 60 - 0
app.dockerfile

@@ -0,0 +1,60 @@
+FROM php:8.2-fpm
+
+# Update packages
+
+RUN apt-get update
+
+# Install PHP and composer dependencies
+
+RUN apt-get install -qq git curl libmcrypt-dev libjpeg-dev libpng-dev libfreetype6-dev libbz2-dev
+
+# Clear out the local repository of retrieved package files
+
+# RUN apt-get clean
+
+# Install needed extensions
+
+# Here you can install any other extension that you need during the test and deployment process
+
+RUN apt-get clean; docker-php-ext-install pdo pdo_mysql mcrypt zip gd pcntl opcache bcmath
+
+# Installs Composer to easily manage your PHP dependencies.
+
+RUN curl –silent –show-error https://getcomposer.org/installer | php — –install-dir=/usr/local/bin –filename=composer
+
+# Install Node
+
+RUN apt-get update &&\
+
+  apt-get install -y –no-install-recommends gnupg &&\
+
+  curl -sL https://deb.nodesource.com/setup_10.x | bash – &&\
+
+  apt-get update &&\
+
+  apt-get install -y –no-install-recommends nodejs &&\
+
+  npm config set registry https://registry.npm.taobao.org –global &&\
+
+  npm install –global gulp-cli
+
+CMD php-fpmNotes:
+
+web:
+
+build:
+
+  context: ./
+
+  dockerfile: web.dockerfile
+
+working_dir: /var/www
+
+volumes_from:
+
+  – app
+
+ports:
+
+  – 8080:80Notes:
+

+ 71 - 9
docker-compose.yml

@@ -1,11 +1,73 @@
-version: '3'
+version: ‘2’
+
 services:
-  app:
-    build:
-      context: .
-      dockerfile: Dockerfile
-    ports:
-      - "8000:80" # 如果需要修改端口,可以在这里修改
-    volumes:
-      - .:/var/www/html
 
+# The Application
+
+app:
+
+  build:
+
+   context: ./
+
+   dockerfile: app.dockerfile
+
+  working_dir: /var/www
+
+  volumes:
+
+   – ./:/var/www
+
+  environment:
+
+   – “DB_PORT=3306”
+
+   – “DB_HOST=database”
+
+# The Web Server
+
+web:
+
+  build:
+
+   context: ./
+
+   dockerfile: web.dockerfile
+
+  working_dir: /var/www
+
+  volumes_from:
+
+   – app
+
+  ports:
+
+   – 8080:80
+
+# The Database
+
+database:
+
+  image: mysql:5.6
+
+  volumes:
+
+   – dbdata:/var/lib/mysql
+
+  environment:
+
+   – “MYSQL_DATABASE=homestead”
+
+   – “MYSQL_USER=homestead”
+
+   – “MYSQL_PASSWORD=root
+
+   – “MYSQL_ROOT_PASSWORD=root
+
+  ports:
+
+    – “33061:3306”
+
+volumes:
+
+dbdata:

+ 11 - 0
docker-composecopy.yml

@@ -0,0 +1,11 @@
+version: '3'
+services:
+  app:
+    build:
+      context: .
+      dockerfile: Dockerfile
+    ports:
+      - "8000:80" # 如果需要修改端口,可以在这里修改
+    volumes:
+      - .:/var/www/html
+

+ 35 - 0
web.dockerfile

@@ -0,0 +1,35 @@
+FROM nginx:1.23.0
+
+ADD vhost.conf /etc/nginx/conf.d/default.conf
+
+server {
+
+  listen 80;
+
+  index index.php index.html;
+
+  root /var/www/public;
+
+  location / {
+
+    try_files $uri /index.php?$args;
+
+  }
+
+  location ~ \.php$ {
+
+    fastcgi_split_path_info ^(.+\.php)(/.+)$;
+
+    fastcgi_pass app:9000;
+
+    fastcgi_index index.php;
+
+    include fastcgi_params;
+
+    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
+
+    fastcgi_param PATH_INFO $fastcgi_path_info;
+
+  }
+
+}Notes: