Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Copy link
Owner Author

@jdecode jdecode commented Sep 30, 2020

This is a version that I am kicking things off with - MySQL, CakePHP, Docker

The gist to create "Noter" setup (developed till now) is being used as a starting point for further development on geartable, although I am pretty sure I would be spending more time on creating this purely separate from Noter, but for now this feels like a very fast and easy way of doing things(in the current/given scope):
https://gist.github.com/jdecode/b2754547a461f289493df38a51776524

Some of the other commands that would be required:

  1. Create "sheets" migration:
    docker-compose run noter bin/cake bake migration CreateSheets id_sheet:string:index:SHEET_ID_INDEX active:boolean? admin_id:uuid? name:string? created:datetime? modified:datetime?

  2. Create "APIs" migration
    docker-compose run noter bin/cake bake migration CreateApis name:string? hash:string:index:HASH_INDEX sheet_id:integer:index:SHEET_ID_INDEX active:boolean? api_range:string:index:API_RANGE_INDEX created:datetime? modified:datetime?

  3. Run migrations (to create tables):
    docker-compose run noter bin/cake migrations migrate

  4. Scaffold MVC :
    docker-compose run noter bin/cake bake all sheets
    docker-compose run noter bin/cake bake all apis

  5. Put the docker instance "up" again:
    docker-compose up

@jdecode

This comment has been minimized.

Copy link
Owner Author

@jdecode jdecode commented Oct 3, 2020

Scrapping everything that is done till now, restarting from using the default CakePHP setup (and using only "users" setup, and not "admins").

Dockerfile also uses the image that is PHP-only (no CakePHP commands/content).

@jdecode

This comment has been minimized.

Copy link
Owner Author

@jdecode 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

This comment has been minimized.

Copy link
Owner Author

@jdecode 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

This comment has been minimized.

Copy link
Owner Author

@jdecode 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:devpass@131.31.1.2/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

This comment has been minimized.

Copy link
Owner Author

@jdecode 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

This comment has been minimized.

Copy link
Owner Author

@jdecode 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

This comment has been minimized.

Copy link
Owner Author

@jdecode 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

This comment has been minimized.

Copy link
Owner Author

@jdecode 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