Skip to content
Permalink
Browse files

add tilt (#1144)

Add tilt for better dev experience
  • Loading branch information...
Yshayy committed Jun 24, 2019
1 parent 254add4 commit 3748fa66abf4848002ec3db6eddaeeba3871425d
Showing with 670 additions and 474 deletions.
  1. +21 −13 CONTRIBUTING.md
  2. +9 −1 README.md
  3. +7 −0 Tiltfile
  4. +183 −0 deployments/dev/tilt.yml
  5. +450 −460 services/authoring/yarn.lock
@@ -50,21 +50,30 @@ Access Tweek gateway using localhost:8081.
Tweek gateway route all traffic to other resources based on: https://github.com/Soluto/tweek/blob/master/services/gateway/settings/settings.json
The root path redirect to Tweek Editor UI

## Using Tilt

Tilt is a CLI tool that can be used to create optimal development environment for multi-container apps such as Tweek, it support automatic rebuliding of images and re-running of containers on files' changes.
Additonally, it support more complex live reloading scenarios such as Tweek Editor (React app).
Tweek uses Tilt on top of docker-compose for easier and (usually) faster developer experience (comapred to Tilt with k8s or Skaffold).

- Install Tilt (https://docs.tilt.dev/install.html)
- tilt up

## Using Skaffold

If you use k8s (comes bundled with Docker for mac/pc, enable using UI), you can use Skaffold (https://github.com/GoogleContainerTools/skaffold).
The main benefit of using Skaffold is that it provide watch, build for all Tweek services (editor has also support for hot code reloading).
Skaffold provides watch, build for all Tweek services and hot code reloading for editor in a similiar way to Tilt.
Since Skaffold/k8s run all services and dependencies together, it can take few minutes to stabilize. (k8s will attempt to restart failed services)

After installing Skaffold, use `skaffold dev --port-forward=false`

## Debugging Tweek editor

1. go to services\editor
2. run yarn
3. run yarn start:full-env

### Debug
If you're not using Skaffold/Tilt, the best way to develop the editor is to run the editor locally against docker-compose:

- run `npm run start:full-env`
1. go to services\editor
2. run `yarn`
3. run `yarn start:full-env`

### Unit Tests

@@ -73,28 +82,27 @@ After installing Skaffold, use `skaffold dev --port-forward=false`
## E2E

1. go to e2e folder
2. run npm i/yarn
2. run `yarn`

### run tests

- if you didn't make any changes to editor, or already built it:
```bash
npm run test:full-env
yarn test:full-env
```
- to rebuild editor and then run tests:
```bash
npm run test:full-env:build
yarn test:full-env:build
```
- our e2e tests are using selenium. If you don't have it installed, and you don't want to install it, you can just run the tests in docker. To do so replace `full-env` with `docker`:
```bash
npm run test:docker
npm run test:docker:build
yarn test:docker
```

## Tear Down

```bash
docker-compose -f ./deployments/dev/docker-compose.yml down --remove-orphans
yarn teardown
```

## Contributing
@@ -40,6 +40,15 @@ The easiest way to start evaluating Tweek is to run it locally on docker, make s

- Run (`yarn start`) - this might take a few minutes for the first time

### Using Tilt

Tilt is a CLI tool that can be used to create optimal development environment for multi-container apps such as Tweek, it support automatic rebuliding of images and re-running of containers on files' changes.
Additonally, it support more complex live reloading scenarios such as Tweek Editor (React app).
Tweek uses Tilt on top of docker-compose for easier and (usually) faster developer experience (comapred to Tilt with k8s).

- Install Tilt (https://docs.tilt.dev/install.html)
- tilt up

### Using Kubernetes

- Install Skaffold (https://github.com/GoogleContainerTools/skaffold)
@@ -126,7 +135,6 @@ More on how multi-variant keys work in Tweek. (link)
### Deployment to production
### FAQ
- Who's using Tweek?
@@ -0,0 +1,7 @@
docker_compose("./deployments/dev/tilt.yml" )
docker_build("soluto/tweek-editor", "services/editor",dockerfile="services/editor/debug.Dockerfile",
live_update=[
fall_back_on(['services/editor/package.json']),
sync('services/editor/src', '/app/src'),
]
)
@@ -0,0 +1,183 @@
secrets:
minio_access_key:
file: ./minio/access_key
minio_secret_key:
file: ./minio/secret_key
tweek_pfx_public_key:
file: ./ssh/tweekgit_public.pfx
tweek_ssh_private_key:
file: ./ssh/tweekgit
tweek_ssh_public_key:
file: ./ssh/tweekgit.pub
services:
api:
build:
args:
target: Debug
context: ../../
dockerfile: TweekApi.Dockerfile
depends_on:
- minio
- nats
- redis
environment:
ASPNETCORE_ENVIRONMENT: Development
PUBLIC_KEY_PATH: /run/secrets/tweek_pfx_public_key
Redis__ConnectionString: redis:6379
Rules__Minio__AccessKeyPath: /run/secrets/minio_access_key
Rules__Minio__Bucket: tweek
Rules__Minio__Endpoint: minio:9000
Rules__Minio__SecretKeyPath: /run/secrets/minio_secret_key
Rules__Nats__Endpoint: nats://nats:4222
RulesetVersionProvider: NatsVersionProvider
UseAddon__Rules: MinioRules
image: soluto/tweek-api
ports:
- published: 4003
target: 80
secrets:
- source: minio_access_key
- source: minio_secret_key
- source: tweek_pfx_public_key
authoring:
build:
context: ../../services/authoring
command:
- yarn
- start:debug
depends_on:
- publishing
environment:
GIT_PRIVATE_KEY_PATH: /run/secrets/tweek_ssh_private_key
GIT_PUBLIC_KEY_PATH: /run/secrets/tweek_ssh_public_key
GIT_URL: ssh://git@publishing/tweek/repo
GIT_USER: git
image: soluto/tweek-authoring
labels:
traefik.port: '3000'
ports:
- published: 4005
target: 3000
- published: 5859
target: 5858
secrets:
- source: tweek_ssh_private_key
- source: tweek_ssh_public_key
editor:
build:
context: ../../services/editor
depends_on:
- gateway
image: soluto/tweek-editor
ports:
- published: 4004
target: 3000
gateway:
build:
context: ../../services/gateway
depends_on:
- api
- authoring
- minio
- nats
- oidc-server-mock
environment:
TWEEKGATEWAY_CONFIGFILEPATH: /config/gateway.json
TWEEKGATEWAY_SECURITY_AUTH_BASICAUTH_REDIRECTURLS: '[''http://localhost:8081'',
''http://localhost:3000'']'
TWEEKGATEWAY_SECURITY_CORS_ALLOWEDHEADERS: '[''*'']'
TWEEKGATEWAY_SECURITY_CORS_ALLOWEDMETHODS: '[''GET'',''POST'',''PUT'',''PATCH'',''DELETE'']'
TWEEKGATEWAY_SECURITY_CORS_ALLOWEDORIGINS: '[''*'']'
TWEEKGATEWAY_SECURITY_CORS_ENABLED: "true"
TWEEKGATEWAY_SECURITY_CORS_MAXAGE: '60'
TWEEKGATEWAY_SECURITY_POLICYSTORAGE_MINIOACCESSKEY: AKIAIOSFODNN7EXAMPLE
TWEEKGATEWAY_SECURITY_POLICYSTORAGE_MINIOBUCKETNAME: tweek
TWEEKGATEWAY_SECURITY_POLICYSTORAGE_MINIOENDPOINT: minio:9000
TWEEKGATEWAY_SECURITY_POLICYSTORAGE_MINIOSECRETKEY: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
TWEEKGATEWAY_SECURITY_POLICYSTORAGE_MINIOSECURE: "false"
TWEEKGATEWAY_SECURITY_POLICYSTORAGE_NATSENDPOINT: nats://nats:4222
TWEEKGATEWAY_SECURITY_TWEEKSECRETKEY_PATH: /run/secrets/tweek_ssh_private_key
image: soluto/tweek-gateway
ports:
- published: 8081
target: 80
secrets:
- source: tweek_ssh_private_key
volumes:
- ./gateway/config:/config:rw
git:
build:
context: ../../services/git-service/BareRepository
environment:
PUBLIC_KEY_PATH: /run/secrets/tweek_ssh_public_key
image: soluto/tweek-bare-repo
ports:
- published: 4001
target: 22
secrets:
- source: tweek_ssh_public_key
minio:
command: server /data
image: minio/minio
ports:
- published: 4007
target: 9000
secrets:
- source: minio_access_key
target: access_key
- source: minio_secret_key
target: secret_key
nats:
image: nats:1.0.4-linux
ports:
- published: 4222
target: 4222
- published: 4008
target: 8222
oidc-server-mock:
container_name: oidc-server-mock
environment:
ASPNETCORE_ENVIRONMENT: Development
OIDC_CLIENT_ID: tweek-openid-mock-client
REDIRECT_URIS: http://localhost:8081/auth-result/oidc
TEST_USER: '{"SubjectId":"user","Username":"user","Password":"pwd"}'
image: soluto/oidc-server-mock
ports:
- published: 8082
target: 80
publishing:
build:
args:
target: Debug
context: ../../services/publishing
depends_on:
- git
- minio
- nats
environment:
GIT_PUBLIC_KEY_PATH: /run/secrets/tweek_ssh_public_key
GIT_SERVER_PRIVATE_KEY_PATH: /run/secrets/tweek_ssh_private_key
GIT_UPSTREAM_URI: ssh://git@git/tweek/repo
MINIO__AccessKey: AKIAIOSFODNN7EXAMPLE
MINIO__Endpoint: minio:9000
MINIO__SecretKeyPath: /run/secrets/minio_secret_key
NATS__Endpoint: nats://nats:4222
image: soluto/tweek-publishing
ports:
- published: 4009
target: 22
- published: 4010
target: 80
secrets:
- source: minio_secret_key
- source: tweek_ssh_private_key
- source: tweek_ssh_public_key
redis:
expose:
- '6379'
image: redis:4.0.2-alpine
ports:
- published: 4006
target: 6379
version: '3.4'

0 comments on commit 3748fa6

Please sign in to comment.
You can’t perform that action at this time.