Преглед на файлове

working docker-compose version. PHINX migration still required.

Mark Lightfoot преди 5 години
родител
ревизия
aa6362c07b
променени са 7 файла, в които са добавени 9115 реда и са изтрити 67 реда
  1. 1 0
      .gitignore
  2. 0 0
      .gitmodules
  3. 9 30
      README.md
  4. 0 8
      db/create_database.sql
  5. 9097 0
      db/setup.sql
  6. 2 1
      docker-compose.yaml
  7. 6 28
      src/index.php

+ 1 - 0
.gitignore

@@ -0,0 +1 @@
+src/*

+ 0 - 0
.gitmodules


+ 9 - 30
README.md

@@ -1,36 +1,15 @@
-# Docker-compose example
+# GE Dev environment
 
-This is a quick example that allows live development on a server. This is very basic and lacks a number of features that would be on an average site (eg fastcgi, redis, etc).
+All you need to do is run `docker-compose up`. Changes are live from the src/ folder. Any DB changes arent saved in this version. set a folder to mount somewhere:/var/lib/mysql/:rw to persist; or edit the db init scripts to get what you want.
 
-It is accessible on `localhost:80`
+##prereqs
+docker (and associated prereqs for that)
+docker-compose
 
-## db folder
+tested on fedora/centos fine. Should be fine with any *nix system.
 
-- Contains create_database.sql
+##windows
 
-This is standard sql to create a database to work off. In the example of cloudM, you'd have an SQL dump or such here to populate the DB. This is referenced in `docker-compose.yaml` 
+Stop being weird, get linux.
 
-```docker-compose.yaml
-volumes:
-      - "./db/:/docker-entrypoint-initdb.d"
-```
-With the specific image used (mysql:5.7) anything placed in the container at docker-entrypoint-initdb.d will be ran as sql files when the database has been created.
-
-## src
- 
-Code lives here. The example here is a simple php file to pull some data from the DB and display it. it is mounted in the docker-compose.yaml so thus can edited on-the-fly without restarts.
-
-## docker-compose.yaml
-
-defines how everything meshes together. run the command `docker-compose up` to bring it all live, with down to tear it away. 
-
-```docker-compose.yaml
-    build: 
-      context: .
-      dockerfile: web-dockerfile
-```
-This defines that the image will be built from a file within the current directory, with web-dockerfile being the Dockerfile.
-
-## web-dockerfile
-
-Creates the docker image. It uses an image from the dockerhub, updates and then enables the mysqli module for php to allow connections. The command `docker-php-ext-install X' is provided by the creators of the docker image.
+It may work if you use win10's linux sub-system (WSL) - though I haven't used it personally so dont know how good it actually is.

+ 0 - 8
db/create_database.sql

@@ -1,8 +0,0 @@
-USE test;
-
-CREATE TABLE test_table (
-  ID int,
-  Name varchar(30)
-);
-
-INSERT INTO test_table (ID, Name) VALUES (1, 'Jeff');

Файловите разлики са ограничени, защото са твърде много
+ 9097 - 0
db/setup.sql


+ 2 - 1
docker-compose.yaml

@@ -23,10 +23,11 @@ services:
     networks:
       - backend
     environment:
+      MYSQL_ROOT_HOST: "%"
       MYSQL_DATABASE: "test"
       MYSQL_USER: "test"
       MYSQL_PASSWORD: "test"
-      MYSQL_ROOT_PASSWORD: "root"
+      MYSQL_ROOT_PASSWORD: "test"
       MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
 
 networks:

+ 6 - 28
src/index.php

@@ -1,29 +1,7 @@
-<?php 
+<?php
+/** FRONT CONTROLLER */
 
-$server = "database";
-$db     = "test";
-$user   = "test";
-$pass  = "test";
-
-$conn = new mysqli($server, $user, $pass, $db);
-
-/*if ($conn->connect_error) {
-    die("conn fail: " . $conn->connect_error);
-}
-echo "connected";
-*/
-
-$query = "SELECT * FROM test_table;";
-$result = $conn->query($query);
-
-if ($result->num_rows > 0) {
-    // output data of each row
-    while($row = $result->fetch_assoc()) {
-        echo "id: " . $row["ID"]. " - Name: " . $row["Name"]. "<br>";
-    }
-} else {
-    echo "0 results";
-}
-$conn->close();
-
-?>
+/** If the location of the application folder moves, this needs to be adapted. */
+define("EMPIRE_APPLICATION", __DIR__ . "/application");
+define("EMPIRE_WEBROOT", __DIR__);
+require_once (EMPIRE_APPLICATION . '/setup.php');