Skip to content

Commit

Permalink
Build for multiple archs, use ./data/service/persist folder to persis…
Browse files Browse the repository at this point in the history
…t data
  • Loading branch information
pflooky committed Jun 8, 2024
1 parent 989191a commit 7666d41
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 37 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,6 @@ jobs:
go mod tidy
go get .
- name: Build
run: go build -o insta-infra .
run: |
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o insta-infra-linux-arm64 .
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o insta-infra-linux-amd64 .
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.idea
__pycache__
data/*/persist
insta-infra*

3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ If any data is persisted from the services to carry across sessions, it gets pus
## Install/Build

```shell
docker run -v ~/code/insta-infra/:/tmp/insta-infra -it golang:1.22.4 bash
go install data-catering/insta-infra
go build -o insta-infra .
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -o insta-infra-darwin-arm64 .
```
27 changes: 13 additions & 14 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
version: "3.9"
services:
#database
cassandra:
Expand All @@ -7,7 +6,7 @@ services:
environment:
- "DS_LICENSE=accept"
volumes:
- "${HOME}/data/cassandra:/var/lib/cassandra"
- "./data/cassandra/persist:/var/lib/cassandra"
- "./data/cassandra/my_data.cql:/docker-entrypoint-initdb.d/my_data.cql"
healthcheck:
test: [ "CMD-SHELL", "[ $$(nodetool statusgossip) = running ]" ]
Expand All @@ -30,8 +29,8 @@ services:
- "ELASTIC_PASSWORD=elasticsearch"
- "discovery.type=single-node"
volumes:
- "./data/elasticsearch/persist:/usr/share/elasticsearch/data:Z"
- "./data/elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml:ro,Z"
- "${HOME}/data/elasticsearch:/usr/share/elasticsearch/data:Z"
ports:
- "9200:9200"
- "9300:9300"
Expand All @@ -46,7 +45,7 @@ services:
- "MARIADB_ROOT_PASSWORD=root"
- "MARIADB_DATABASE=customer"
volumes:
- "${HOME}/data/mariadb:/var/lib/mysql:Z"
- "./data/mariadb/persist:/var/lib/mysql:Z"
- "./data/mariadb:/opt/app"
ports:
- "3306:3306"
Expand All @@ -59,7 +58,7 @@ services:
- "MONGO_INITDB_ROOT_USERNAME=user"
- "MONGO_INITDB_ROOT_PASSWORD=password"
volumes:
- "${HOME}/data/mongodb:/data/db"
- "./data/mongodb/persist:/data/db"
ports:
- "27017:27017"

Expand All @@ -81,7 +80,7 @@ services:
- "MYSQL_ROOT_PASSWORD=root"
command: "--mysql-native-password=ON"
volumes:
- "${HOME}/data/mysql:/var/lib/mysql"
- "./data/mysql/persist:/var/lib/mysql"
- "./data/mysql/my_data.sql:/docker-entrypoint-initdb.d/my_data.sql"
healthcheck:
test: [ "CMD-SHELL", "mysqladmin" ,"ping", "-h", "localhost", "-u", "root", "-p$$MYSQL_ROOT_PASSWORD" ]
Expand All @@ -98,7 +97,7 @@ services:
- "POSTGRES_PASSWORD=postgres"
- "PGDATA=/data/postgres"
volumes:
- "${HOME}/data/postgres:/data/postgres"
- "./data/postgres/persist:/data/postgres"
- "./data/postgres/my_data.sql:/docker-entrypoint-initdb.d/my_data.sql"
healthcheck:
test: [ "CMD-SHELL", "pg_isready" ]
Expand All @@ -122,7 +121,7 @@ services:
- "POSTGRES_USER=postgres"
- "POSTGRES_PASSWORD=postgres"
volumes:
- "${HOME}/data/marquez:/opt/marquez"
- "./data/marquez/persist:/opt/marquez"
- "./data/marquez:/opt/app"
ports:
- "5002:5000"
Expand Down Expand Up @@ -288,7 +287,7 @@ services:
- "DAGSTER_POSTGRES_DB=dagster"
- "DAGSTER_HOME=/opt/dagster/dagster_home/"
volumes:
- "${HOME}/data/dagster:/opt/dagster/dagster_home/"
- "./data/dagster/persist:/opt/dagster/dagster_home/"
- "./data/dagster:/opt/dagster/app/"
ports:
- "3000:3000"
Expand All @@ -305,7 +304,7 @@ services:
ports:
- "6789:6789"
volumes:
- "${HOME}/data/mage-ai:/home/src/"
- "./data/mage-ai/persist:/home/src/"
restart: "on-failure"

prefect-server:
Expand All @@ -318,7 +317,7 @@ services:
- "PREFECT_SERVER_API_HOST=0.0.0.0"
- "PREFECT_API_DATABASE_CONNECTION_URL=postgresql+asyncpg://postgres:postgres@postgres:5432/prefect"
volumes:
- "${HOME}/data/prefect:/root/.prefect"
- "./data/prefect/persist:/root/.prefect"
ports:
- "4200:4200"
depends_on:
Expand Down Expand Up @@ -349,7 +348,7 @@ services:
- "KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://kafka:29092,PLAINTEXT_HOST://localhost:9092"
- "KAFKA_LISTENERS=PLAINTEXT://kafka:29092,CONTROLLER://localhost:29093,PLAINTEXT_HOST://0.0.0.0:9092"
volumes:
- "${HOME}/data/kafka:/var/lib/kafka/data"
- "./data/kafka/persist:/var/lib/kafka/data"
healthcheck:
test: [ "CMD-SHELL", "/bin/sh", "-c", "kafka-topics", "--bootstrap-server", "kafka:29092", "--list" ]
interval: "15s"
Expand Down Expand Up @@ -378,7 +377,7 @@ services:
- "username_admin_password=admin"
- "system_scaling_maxconnectioncount=100"
volumes:
- "${HOME}/data/solace:/var/lib/solace"
- "./data/solace/persist:/var/lib/solace"
healthcheck:
test: [ "CMD-SHELL", "curl", "--output", "/dev/null", "--silent", "--head", "--fail", "http://localhost:8080" ]
interval: "30s"
Expand Down Expand Up @@ -417,7 +416,7 @@ services:
- "MINIO_ROOT_USER=minioadmin"
- "MINIO_ROOT_PASSWORD=minioadmin"
volumes:
- "${HOME}/data/minio:/data"
- "./data/minio/persist:/data"
ports:
- "9000:9000"
- "9001:9001"
Expand Down
9 changes: 3 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
module data-catering/insta-infra

go 1.21
go 1.22

require (
github.com/compose-spec/compose-go/v2 v2.1.1
github.com/docker/cli v26.1.4+incompatible
github.com/docker/compose/v2 v2.27.1
github.com/docker/docker v26.1.4+incompatible // indirect
)

require (
github.com/compose-spec/compose-go/v2 v2.1.1
github.com/urfave/cli/v2 v2.27.2
)

Expand Down Expand Up @@ -51,6 +47,7 @@ require (
github.com/distribution/reference v0.6.0 // indirect
github.com/docker/buildx v0.14.1 // indirect
github.com/docker/distribution v2.8.3+incompatible // indirect
github.com/docker/docker v26.1.3+incompatible // indirect
github.com/docker/docker-credential-helpers v0.8.0 // indirect
github.com/docker/go v1.5.1-1.0.20160303222718-d30aec9fd63c // indirect
github.com/docker/go-connections v0.5.0 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ github.com/docker/compose/v2 v2.27.1/go.mod h1:JZVWp9uVnP59S3KoVne6MboJRpx/eNr9H
github.com/docker/distribution v2.7.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
github.com/docker/distribution v2.8.3+incompatible h1:AtKxIZ36LoNK51+Z6RpzLpddBirtxJnzDrHLEKxTAYk=
github.com/docker/distribution v2.8.3+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
github.com/docker/docker v26.1.4+incompatible h1:vuTpXDuoga+Z38m1OZHzl7NKisKWaWlhjQk7IDPSLsU=
github.com/docker/docker v26.1.4+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
github.com/docker/docker v26.1.3+incompatible h1:lLCzRbrVZrljpVNobJu1J2FHk8V0s4BawoZippkc+xo=
github.com/docker/docker v26.1.3+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
github.com/docker/docker-credential-helpers v0.8.0 h1:YQFtbBQb4VrpoPxhFuzEBPQ9E16qz5SpHLS+uswaCp8=
github.com/docker/docker-credential-helpers v0.8.0/go.mod h1:UGFXcuoQ5TxPiB54nHOZ32AWRqQdECoh/Mg0AlEYb40=
github.com/docker/go v1.5.1-1.0.20160303222718-d30aec9fd63c h1:lzqkGL9b3znc+ZUgi7FlLnqjQhcXxkNM/quxIjBVMD0=
Expand Down
20 changes: 7 additions & 13 deletions insta.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ func main() {
EnableBashCompletion: true,
Commands: []*cli.Command{
{
Usage: "Run services",
Name: "run",
Aliases: []string{"-r"},
Usage: "Run services",
Action: func(cCtx *cli.Context) error {
err := runServices(ctx, srv, p, cCtx.Args().Slice())
if err != nil {
Expand All @@ -47,18 +49,9 @@ func main() {
return nil
},
},
{
Name: "run",
Aliases: []string{"r"},
Usage: "Run services",
Action: func(cCtx *cli.Context) error {
fmt.Println("run task: ", cCtx.Args().First())
return nil
},
},
{
Name: "connect",
Aliases: []string{"c"},
Aliases: []string{"-c"},
Usage: "Connect to a service",
Action: func(cCtx *cli.Context) error {
fmt.Println("connect task: ", cCtx.Args().First())
Expand All @@ -67,7 +60,7 @@ func main() {
},
{
Name: "down",
Aliases: []string{"d"},
Aliases: []string{"-d"},
Usage: "Bring all services down",
Action: func(cCtx *cli.Context) error {
err := downServices(ctx, srv, p, cCtx.Args().Slice())
Expand All @@ -79,14 +72,15 @@ func main() {
},
{
Name: "update",
Aliases: []string{"u"},
Aliases: []string{"-u"},
Usage: "Update to the latest service versions",
Action: func(cCtx *cli.Context) error {
fmt.Println("update task: ", cCtx.Args().First())
return nil
},
},
},
DefaultCommand: "--help",
}

if err := app.Run(os.Args); err != nil {
Expand Down

0 comments on commit 7666d41

Please sign in to comment.