Code Monkey home page Code Monkey logo

sync-stat's Introduction

Docker Storage Sync for Faster Development on MacOS and Windows

!Still only works on MacOS, documentation is also incomplete. please wait till release 1.0 +

Pleast note that this is a pre-release, functionality is still partial!
Wait for a newer update!!

CodeQL Node.js Package


What it does

sync-stat is an NPX CLI toolkit that offers an alternative to Docker Bind Mounts that is on par with Bind mounts on Linux Based FSs in terms of performance for MacOS.(Windows NTFS support is comming soon)

Docker with bind mounts can really cause a major performance penalty in MacOS (APPFS) and windows (NTFS)

Windows has WSL so it's not really effected but it would be nice if it would work as fast as bind mounts in linux in NTFS

sync-stat also offers some other options that docker cp / bind mounts do not offer. such as the ability to set an explicit user group and mode to the directory


Installation

Install via NPM

npm i sync-stat

Configure - create sync-compose.yaml

create a YAML file named sync-compose.yaml at the root directory of your project

version: 1

containers: #Array
  - name-of-container: #Array - must be defined in docker-compose or name container on start
      volumes: # Bind Mounts - Array
        - volume: # Item - config for each bind
            profile: local # profile names will group volumes, can use run <profilename> to activate only the volumes in the group. if empty it will be activated too.
            from: app/ # From location relative to <ProjectRoot> => app/  || does not support ./app yet
            to: /var/www/html/ # to location inside docker container
            mode: 775 # Mode to write files
            owner: www-data:www-data # owner to write files as
            cmd: #Run the Following commands on start, this only runs 1 time
              - npm install
              - composer install
            ignore: #ignore these directories when syncing
              - node_modules/
            replace: # replace these strings when copying
              - 'localhost:mysql-db'

database:
  driver: mysql # Currently only mysql is supported
  profile: staging # Profiles
  method: export # [ export | dump ]
  file: /path/to/dump.sql #[ ./relative | /absolute ]/path/to/dump.sql . will only be used when method is in export
  server: # externel server config
    database_user: user
    database_name: dbname
    database_pass: pass
    host: server.name
    port: 3306
  local: # local server config. external servers can  be used too
    provision: true # drop db if it exists, create if not exist. needs root password
    database_user: user
    database_name: dbname
    database_pass: pass
    root_password: root_password # only used for provision function
    host: localhost
    port: 3306

Example

docker-compose.yml

version: '3.9'

services:
  wordpress:
    container_name: mytest-container
    image: some-image #REPLACE
    volumes:
      - ./app:/var/www/html # (IMPORTANT!) REMOVE THIS. sync-stat will Automaticall do this
      # MOUNT CANNOT MATCH THE ONE IN SYNC-COMPOSE
      # IF YOU DONT REMOVE THAT LINE, IT WILL CAUSE AN ERROR.
    ports:
      - '8000:80'
    ## application is placed at /var/www/html

sync-compose.yaml

version: 1

containers:
  - mytest-container:
      volumes:
        - volume:
            profile: local
            from: app/
            to: /var/www/html/
            mode: 775
            owner: www-data:www-data
            cmd:
              - echo hi
            ignore:
              - node_modules/
            replace:
              - 'string:string'

RUN

Start your docker container or compose setup

make sure to name the container with matching names defined in the sync-compose.json

Start Sync

Once Containers are online run the following in the root directory

npx syncstat run

running profiles

npx syncstat run <profilename>

when using run <profilename>, only volumes that match the profile name will be added. volumes without profile names will be added as well.

Running DB

npx syncstat db

or with profiles

npx syncstat db <profile>

sync-stat's People

Contributors

blazeisclone avatar janithcooray avatar vimarshacooray avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

sync-stat's Issues

Template test

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

Windows Support Blog

Windows support is under development

Unlike Linux and MacOS , we plan to be using PS for Core functions

Major differences are present as for Paths and Line Ends

Auto DB dump and import to local

Adding an option to download a DB copy directly from the DB server or import from a SQL dump

database:
  driver: mysql
  profile: staging
  method: [ export | dump ]
  file: [ ./relative | /absolute ]/path/to/dump.sql
  server:
    database_user: 
    database_name:
    database_pass:
    host:
    port: 
  local:
    database_user: 
    database_name:
    database_pass:
    root_password:
    host:
    port: 

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.