Skip to content

Commit bd88a29

Browse files
authored
Merge pull request #33 from typecode/develop
Version 0.4.0
2 parents 0e28038 + da1c449 commit bd88a29

File tree

12 files changed

+122
-555
lines changed

12 files changed

+122
-555
lines changed

.githooks/post-commit

Lines changed: 0 additions & 4 deletions
This file was deleted.

README.md

Lines changed: 12 additions & 199 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ Sykle is a cli tool for calling commonly used commands in docker-compose project
44

55
#### What sykle does
66

7-
87
- Enforces 3 docker-compose environments: `dev`, `test`, and `prod`
98
- Provides commands for spinning up dev, running tests, and deploying to prod
109
- (Assumes you are deploying to a single remote instance running docker-compose)
@@ -38,7 +37,7 @@ Sykle is a cli tool for calling commonly used commands in docker-compose project
3837

3938
### Configuration
4039

41-
Because sykle tries to make as few assumptions about your project as possible, you'll need to declaritively define how your app should run via static configuration files
40+
Because sykle tries to make as few assumptions about your project as possible, you'll need to declaratively define how your app should run via static configuration files
4241

4342
#### Docker Compose
4443

@@ -53,211 +52,27 @@ These separate configurations allow you to tweak how your projects run in those
5352

5453
#### .sykle.json
5554

56-
In addition to your `docker-compose` files, you'll need a `.sykle.json`. An example is listed below. This example can be viewed from the cli via `syk config`
57-
58-
*Example:*
59-
```js
60-
61-
{
62-
// specifies which version of .sykle.json is being used
63-
"version": 2,
64-
// name of the project (used when naming docker images)
65-
"project_name": "cool-project",
66-
// docker compose service to use for commands by default (EX: for syk dc_run)
67-
"default_service": "django",
68-
// list of commands needed to run unittests (run sequentially)
69-
"unittest": [
70-
{
71-
// docker compose service on which to run the command
72-
"service": "django",
73-
// command invoked via 'docker-compose run --rm <service>'
74-
"command": "django-admin test"
75-
},
76-
{
77-
"service": "node",
78-
"command": "npm test"
79-
}
80-
],
81-
// list of commands needed to run e2e tests (run sequentially)
82-
"e2e": [
83-
{
84-
"service": "django",
85-
"command": "behave"
86-
}
87-
],
88-
// list of commands to invoke before deploying (run sequentially)
89-
"predeploy": [
90-
{
91-
"service": "django",
92-
"command": "django-admin collectstatic --no-input"
93-
}
94-
],
95-
// deployment to use by default (must be listed in deployments section)
96-
"default_deployment": "staging",
97-
// a collection of locations where you can deploy the project to.
98-
// each remote instance is assumed to:
99-
// - be accessible via ssh
100-
// - have docker installed
101-
// - have docker-compose installed
102-
// the machine you are deploying from is assumed to:
103-
// - have ssh access to the remote machine
104-
// - have the 'ssh' command
105-
// - have the 'scp' command
106-
// - have docker installed
107-
// - have docker-compose installed
108-
"deployments": {
109-
// the location of the deployment (EX: 'syk --location=prod deploy')
110-
"prod": {
111-
// the ssh address of the machine the deployment should point to
112-
"target": "[email protected]",
113-
// environment to use when the deployment is running
114-
"env": ".env.prod",
115-
// docker_vars are variables that are made available to the
116-
// prod-build and prod docker compose files
117-
"docker_vars": {
118-
"SERVICE_IMAGE": "some-ecr-url/prod-repo",
119-
// if a variable begins with a $ sign, it will pull the value
120-
// from that environment value
121-
"BUILD_NUMBER": "$BUILD_NUMBER"
122-
}
123-
},
124-
// multiple deployments can be listed
125-
"staging": {
126-
"target": "[email protected]",
127-
"env": ".env.staging",
128-
"docker_vars": {
129-
"SERVICE_IMAGE": "some-ecr-url/staging-url",
130-
"BUILD_NUMBER": "$BUILD_NUMBER"
131-
}
132-
}
133-
},
134-
// defines shortcuts for commonly used commands
135-
"aliases": {
136-
// name of the command (would type 'syk dj <INPUT>' to use)
137-
"dj": {
138-
"service": "django",
139-
"command": "django-admin"
140-
}
141-
},
142-
// defines settings specific to plugins
143-
"plugins": {
144-
// name of the plugin the settings apply to
145-
"sync_pg_data": {
146-
"staging": {
147-
"env_file": ".env.staging",
148-
"args": {
149-
"HOST": "storefront.staging.sharptype.co",
150-
"PASSWORD": "$POSTGRES_PASSWORD",
151-
"USER": "$POSTGRES_USER",
152-
"NAME": "$POSTGRES_DB"
153-
}
154-
},
155-
"local": {
156-
"env_file": ".env",
157-
"write": true,
158-
"args": {
159-
"HOST": "localhost",
160-
"PASSWORD": "thisisbogus",
161-
"USER": "sharptype",
162-
"NAME": "sharptype",
163-
"PORT": 8887
164-
}
165-
}
166-
}
167-
}
168-
}
169-
170-
```
55+
In addition to your `docker-compose` files, you'll need a `.sykle.json`. An example detailing how to build a config file can be viewed from the cli via `syk config`
17156

17257
### Usage
17358

17459
Usage instructions can be viewed after installation with `syk --help`
17560

17661
This will not show any info for plugins. In order to view installed plugins, run `syk plugins`. To view help for a specfic plugin, run `syk <plugin_name> --help`.
17762

178-
```
179-
Sykle CLI
180-
Usage:
181-
syk [--debug] [--config=<file>] [--test | --prod | --prod-build] dc [INPUT ...]
182-
syk [--debug] [--config=<file>] [--test | --prod | --prod-build] [--service=<service>] [--env=<env_file>] dc_run [INPUT ...]
183-
syk [--debug] [--config=<file>] [--test | --prod] [--service=<service>] dc_exec [INPUT ...]
184-
syk [--debug] [--config=<file>] [--test | --prod] [--deployment=<name>] build
185-
syk [--debug] [--config=<file>] [--test | --prod] up
186-
syk [--debug] [--config=<file>] [--test | --prod] down
187-
syk [--debug] [--config=<file>] [--service=<service>] unittest [INPUT ...]
188-
syk [--debug] [--config=<file>] [--service=<service>] e2e [INPUT ...]
189-
syk [--debug] [--config=<file>] [--deployment=<name>] push
190-
syk [--debug] [--config=<file>] [--deployment=<name>] ssh
191-
syk [--debug] [--config=<file>] [--deployment=<name>] [--dest=<dest>] ssh_cp [INPUT ...]
192-
syk [--debug] [--config=<file>] [--deployment=<name>] ssh_exec [INPUT ...]
193-
syk [--debug] [--config=<file>] [--env=<env_file>] [--deployment=<name>] deploy
194-
syk init
195-
syk plugins
196-
syk config
197-
syk [--debug] [--config=<file>] [INPUT ...]
198-
199-
Option
200-
-h --help Show help info
201-
--version Show version
202-
--test Run command with test compose file
203-
--prod Run command with prod compose file
204-
--prod-build Run command with prod-build compose file
205-
--config=<file> Specify JSON config file
206-
--dest=<dest> Destination path [default: ~]
207-
--env=<env_file> Env file to use [default: .env]
208-
--service=<service> Docker service on which to run the command
209-
--debug Prints debug information
210-
--deployment=<name> Uses config for the given deployment
211-
212-
Description:
213-
dc Runs docker-compose command
214-
dc_run Spins up and runs a command on a docker-compose service
215-
dc_exec Runs a command on an existing docker-compose container
216-
build Builds docker-compose images
217-
up Starts docker-compose
218-
down Stops docker-compose
219-
unittest Runs unittests on all services defined in "unittest"
220-
e2e Runs end to end tests on all services defined in "e2e"
221-
push Pushes images using "docker-compose.prod-build.yml"
222-
ssh Connects to the ssh target
223-
ssh_cp Copies file to ssh target home directory
224-
ssh_exec Executes command on ssh target
225-
deploy Deploys and starts latest builds on ssh target
226-
init Creates a blank config file
227-
plugins Lists available plugins
228-
config Print an example config
63+
### Legacy ./run.sh
22964

230-
```
65+
Prior to sykle, the predominate pattern at typecode was to create a `./run.sh` file with a list of commands. For convenience, if a `./run.sh` file is found, sykle will try to run commands through `./run.sh` before running through sykle.
23166

232-
### Development
67+
### Running Tests (for sykle)
23368

234-
The README for the main package and each global plugin is generated via mustache (actual README.md files are read only). This allows us to insert the docstrings (which determine command line arguments) into each README so they stay up to date automatically.
69+
Unittests (that test sykle) can be run via `python setup.py test`
23570

236-
When you pull down the repo for the first time, you should run the following command:
237-
238-
```sh
239-
git config core.hooksPath .githooks
240-
```
241-
242-
This will make it so that after commit, if there has been a change to the docstrings, an additional "Update README" commit will be created with up to date documentation.
243-
244-
#### Githook Requirements
245-
246-
You will need to install `chevron` for the githooks to work:
247-
248-
```sh
249-
pip install chevron
250-
```
251-
252-
#### Running Tests
253-
254-
Unittests can be run via `python setup.py test`
255-
256-
#### Writing plugins
71+
### Writing plugins
25772

25873
There are two types of plugins: **global** plugins and **local** plugins.
25974

260-
##### Local Plugins
75+
#### Local Plugins
26176

26277
Local plugins allow you to create project specific commands. If you have a command or series of commands that you run frequently for a project that are more complicated than an alias, it might make sense to create a local plugin.
26378

@@ -266,7 +81,7 @@ To create a local plugin:
26681
1. Create a `.sykle-plugins/` directory in the root of your project (`.sykle-plugins/` should be in same directory as `.sykle.json`)
26782
2. Add an `__init__.py` file to `.sykle-plugins/`
26883
3. Add a python file for your plugin to `.sykle-plugins/` (EX: `.sykle-plugins/my_plugin.py`)
269-
4. Define your plugin like in the exapmle below:
84+
4. Define your plugin like in the example below:
27085

27186
Example
27287
```py
@@ -302,21 +117,19 @@ Note that `syk` is present in the docopt usage definition before the plugin comm
302117

303118
If you defined your plugin correctly, you should be able to see listed when calling `syk plugins`
304119

305-
##### Global Plugins
120+
#### Global Plugins
306121

307122
Global plugins are the same as local plugins, but they are added to the `plugins` folder of this repo and are available to anyone who installs sykle.
308123

309-
Any `README.mustache` defined in a plugin folder will have a usage variable provided to it, and will result in a `README.md` being created when code is commited
310-
311124
### Roadmap
312125

313126
- [x] Move to separate repo
314127
- [x] Allow user to specify `test` commands
315128
- [x] Add plugins
316-
- [x] REAMDE.md generation on ~push to repo~ commit
317129
- [x] Add `init` command to create `.sykle.json`
318-
- [ ] Fallback to `./run.sh` if it exists and `.sykle.json` does not
319130
- [x] ~Scripts section in `.sykle.json`~ Local plugins
131+
- ~REAMDE.md generation on commit~ (unecessarily complex)
132+
- [x] Fallback to `./run.sh` if it exists and `.sykle.json` does not
320133
- [ ] User aliases/way to share aliases
321134
- [ ] Terraform support
322135
- [ ] Revisit whether `docker-compose` files can/should be shared

0 commit comments

Comments
 (0)