Skip to content

Instantly share code, notes, and snippets.

@jdecode
Created September 27, 2020 18:05
Show Gist options
  • Save jdecode/f25b66b8993d5ca32c4a25353e9f2ec9 to your computer and use it in GitHub Desktop.
Save jdecode/f25b66b8993d5ca32c4a25353e9f2ec9 to your computer and use it in GitHub Desktop.
Geartable development

Actual code has not started yet and I have been thinking about several ways to accompalish this:

  1. CakePHP, MySQL - No Vue/TailwindCSS/DynamoDB
  2. Slim(PHP), Postgres, Vue/TailwindCSS
  3. Slim(PHP), DynamoDB, Vue/Tailwindcss

Fastest one (for now) would be the first option - more experience, recently worked on this a lot

Taking specific notes from "Noter" development - more on this tomorrow

@jdecode
Copy link
Author

jdecode commented Oct 3, 2020

Dockerfile uses the image jdecode/php7.4:2

And the above image is created by using the following commands:

FROM php:7.4-apache

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

#duh!
RUN apt-get update

#Install zip+icu dev libs
RUN apt-get install libzip-dev zip libicu-dev -y

#Install PHP extensions zip and intl (intl requires to be configured)
RUN docker-php-ext-install zip && docker-php-ext-configure intl && docker-php-ext-install intl

# MySQL (replace with Postgres extension commands if using that)
RUN docker-php-ext-install mysqli pdo pdo_mysql && docker-php-ext-enable pdo_mysql

#Required for htaccess rewrite rules
RUN a2enmod rewrite

@jdecode
Copy link
Author

jdecode commented Oct 3, 2020

For the application, the Dockerfile that is used is as following:

FROM jdecode/php7.4:2

COPY composer.json .
RUN composer install -n --prefer-dist

COPY . .

ARG BUILD
ENV BUILD=${BUILD}

## Disabled following when running locally (keep it enabled for GCP Cloud Run)
RUN if [ "$BUILD" = "local" ] ; then ls -al ; else sed -i 's/80/${PORT}/g' /etc/apache2/sites-available/000-default.conf /etc/apache2/ports.conf ; fi

@jdecode
Copy link
Author

jdecode commented Oct 3, 2020

The docker-compose.yml file is as follow:

version: "3"
services:
  geartable:
    build:
      context: .
      dockerfile: Dockerfile
      args:
        BUILD: 'local'
    image: geartable:1.0
    ports:
      - 8080:80
    volumes:
      - .:/var/www/html
    links:
      - mysql
    depends_on:
      - mysql
    environment:
      DEBUG: 'true'
      SECURITY_SALT: 49e558df8e733a6daedbe054a9ccd7add9d9a6efa8a96cf3248815c364b47391
      DATABASE_URL: mysql://devuser:[email protected]/geartable
    networks:
      gear_net:
        ipv4_address: 131.31.1.1

  mysql:
    image: mysql:5.7
    environment:
      MYSQL_ROOT_PASSWORD: password
      MYSQL_DATABASE: geartable
      MYSQL_USER: devuser
      MYSQL_PASSWORD: devpass
    ports:
      - 9906:3306
    networks:
      gear_net:
        ipv4_address: 131.31.1.2
volumes:
  db_data: {}
networks:
  gear_net:
    ipam:
      driver: default
      config:
        - subnet: 131.31.0.0/16

@jdecode
Copy link
Author

jdecode commented Oct 3, 2020

Keeping these 2 files in a separate folder (to be moved to the main application code later), in a new empty folder run the following command to install CakePHP (using composer):

composer create-project -n --prefer-dist cakephp/app ./

@jdecode
Copy link
Author

jdecode commented Oct 3, 2020

Now move the Dockerfile and docker-compose.yml files (created earlier) to the CakePHP folder.

Additionally, I overwrote the readme file (that's entirely optional for you).

I pushed the code now (CakePHP + Dockerfile + docker-compose.yml) to the git repo here:
https://github.com/jdecode/geartable

@jdecode
Copy link
Author

jdecode commented Oct 3, 2020

Either you can use the steps mentioned above to reach a point where you have CakePHP setup using Docker, or you can clone the repo at https://github.com/jdecode/geartable and follow the instructions

@jdecode
Copy link
Author

jdecode commented Oct 12, 2020

docker-compose run geartable bin/cake bake migration CreateCategories name:string:index:NAME_INDEX photo:string? active:boolean? added:datetime?

docker-compose run geartable bin/cake bake migration CreateProducts category_id:number:index:CATEGORY_ID_INDEX name:string photo:string? active:boolean? added:datetime?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment