diff --git a/Dockerfile.Payroll.server b/Dockerfile.Payroll.server new file mode 100644 index 0000000..774f689 --- /dev/null +++ b/Dockerfile.Payroll.server @@ -0,0 +1,47 @@ +# Use the official Go image as the base image +FROM golang:1.24 as builder + +# Set the working directory +WORKDIR /app + +# Copy go.mod and go.sum to install dependencies +COPY go.mod go.sum ./ +RUN go mod download + +# Copy the source code +COPY . . + +RUN wget https://github.com/vultisig/go-wrappers/archive/refs/heads/master.tar.gz +RUN tar -xzf master.tar.gz && \ + cd go-wrappers-master && \ + mkdir -p /usr/local/lib/dkls && \ + cp --recursive includes /usr/local/lib/dkls + +ENV LD_LIBRARY_PATH=/usr/local/lib/dkls/includes/linux/:$LD_LIBRARY_PATH + +# Build the application +RUN go build -o server ./cmd/payroll/server + +# Use a minimal base image for the final stage +FROM ubuntu:24.04 + +RUN apt-get update && \ + apt-get install -y wget && \ + rm -rf /var/lib/apt/lists/* + +# Set the working directory +WORKDIR /app + +# Copy the built binary from the builder stage +COPY --from=builder /app/server . +COPY --from=builder /usr/local/lib/dkls /usr/local/lib/dkls +COPY payroll.server.example.json config.json +COPY ./etc/vultisig/payroll.yml /etc/vultisig/payroll.yml + +ENV LD_LIBRARY_PATH=/usr/local/lib/dkls/includes/linux/:$LD_LIBRARY_PATH + +# Expose the port the application listens on +EXPOSE 8080 + +# Run the application +CMD ["./server"] \ No newline at end of file diff --git a/Dockerfile.Payroll.worker b/Dockerfile.Payroll.worker new file mode 100644 index 0000000..319065e --- /dev/null +++ b/Dockerfile.Payroll.worker @@ -0,0 +1,44 @@ +# Use the official Go image as the base image +FROM golang:1.24 as builder + +# Set the working directory +WORKDIR /app + +# Copy go.mod and go.sum to install dependencies +COPY go.mod go.sum ./ +RUN go mod download + +# Copy the source code +COPY . . + +RUN wget https://github.com/vultisig/go-wrappers/archive/refs/heads/master.tar.gz +RUN tar -xzf master.tar.gz && \ + cd go-wrappers-master && \ + mkdir -p /usr/local/lib/dkls && \ + cp --recursive includes /usr/local/lib/dkls + +ENV LD_LIBRARY_PATH=/usr/local/lib/dkls/includes/linux/:${LD_LIBRARY_PATH:-} + +# Build the application +RUN go build -o worker ./cmd/payroll/worker + +# Use a minimal base image for the final stage +FROM ubuntu:24.04 + +RUN apt-get update && \ + apt-get install -y wget && \ + rm -rf /var/lib/apt/lists/* + +# Set the working directory +WORKDIR /app + +# Copy the built binary from the builder stage +COPY --from=builder /app/worker . +COPY --from=builder /usr/local/lib/dkls /usr/local/lib/dkls +COPY payroll.worker.example.json config.json +COPY ./etc/vultisig/payroll.yml /etc/vultisig/payroll.yml + +ENV LD_LIBRARY_PATH=/usr/local/lib/dkls/includes/linux/:${LD_LIBRARY_PATH:-} + +# Run the application +CMD ["./worker"] \ No newline at end of file diff --git a/Makefile b/Makefile index a59e451..556ee14 100644 --- a/Makefile +++ b/Makefile @@ -7,17 +7,6 @@ up: down: @docker compose down -verifier-server: - @DYLD_LIBRARY_PATH=$(DYLD_LIBRARY) VS_CONFIG_NAME=config-verifier go run cmd/vultisigner/main.go - -verifier-worker: - @DYLD_LIBRARY_PATH=$(DYLD_LIBRARY) VS_CONFIG_NAME=config-verifier go run cmd/worker/main.go - -plugin-server: - @DYLD_LIBRARY_PATH=$(DYLD_LIBRARY) VS_CONFIG_NAME=config-plugin go run cmd/vultisigner/main.go - -plugin-worker: - @DYLD_LIBRARY_PATH=$(DYLD_LIBRARY) VS_CONFIG_NAME=config-plugin go run cmd/worker/main.go # Dump database schema # Usage: make dump-schema CONFIG=config-plugin.yaml diff --git a/README.md b/README.md index ec8ff3a..3d892de 100644 --- a/README.md +++ b/README.md @@ -12,33 +12,6 @@ Vultisigner / VultiServer consists of two components: ## Ping `/ping` , it provide a simple health check for the Api Server , the return value is `Vultisigner is running` -## Keygen -`POST` `/vault/create` -### Keygen Request -```json -{ - "name": "My Vault", - "session_id": "session id for key generation", - "hex_encryption_key": "hex encoded encryption key", - "hex_chain_code": "hex encoded chain code", - "local_party_id": "local party id", - "encryption_password": "password to encryption the generated vault share", - "email": "email of the user", - "lib_type": "type of the library" -} -``` -- name: Vault name -- session_id: Key generation session ID (random UUID) -- hex_chain_code: 32-byte hex encoded string -- hex_encryption_key: 32-byte hex encoded string for encryption/decryption -- local_party_id: Identifier for VultiServer in the keygen session -- encryption_password: Password to encrypt the vault share -- email: Email to send the encrypted vault share -- lib_type: Type of the library (e.g., 0 for GG20 , 1 for DKLS) -- -### Response - -Status Code: OK ## Keysign `POST` `/vault/sign` , it is used to sign a transaction @@ -68,9 +41,8 @@ Status Code: OK - vault_password: Password to decrypt the vault share ## Get Vault -`GET` `/vault/get/{publicKeyECDSA}` , this endpoint allow user to get the vault information +`GET` `/vault/get/:pluginId/{publicKeyECDSA}` , this endpoint allow user to get the vault information -Note: please set `x-password` header with the password to decrypt the vault share , if the password is empty or incorrect, server will return an error ### Response ```json { @@ -94,11 +66,9 @@ Note: please set `x-password` header with the password to decrypt the vault shar "hex_encryption_key": "hex encoded encryption key", "hex_chain_code": "hex encoded chain code", "local_party_id": "local party id", - "old_parties": ["old party id 1", "old party id 2"], - "encryption_password": "password to encryption the generated vault share", - "email": "email of the user", + "old_parties": ["old party id 1", "old party id 2"], "old_reshare_prefix":"old reshare prefix", - "lib_type": "type of the library" + "plugin_id": "payroll-plugin-0000" } ``` - name: Vault name @@ -108,27 +78,9 @@ Note: please set `x-password` header with the password to decrypt the vault shar - hex_chain_code: 32-byte hex encoded string - local_party_id: Identifier for VultiServer in the reshare session - old_parties: List of old party IDs -- encryption_password: Password to encrypt the vault share -- email: Email to send the encrypted vault share -- lib_type: Type of the library (e.g., 0 for GG20 , 1 for DKLS) - -## Resend vault share and verification code -`POST` `/vault/resend` , this endpoint allow user to resend the vault share and verification code -Note: user can only request a resend every three minutes -### Resend Request -```json -{ - "public_key_ecdsa": "ECDSA public key of the vault", - "password": "password to decrypt the vault share", - "email": "email of the user" -} -``` -## Verify code -`GET` `/vault/verify/:public_key_ecdsa/:code` , this endpoint allow user to verify the code -if server return http status code 200, it means the code is valid , other status code means the code is invalid -## How to setup vultisigner to run locally? +## How to setup plugin to run locally? # Setup Guide @@ -142,334 +94,18 @@ if server return http status code 200, it means the code is valid , other status First, start the required infrastructure services using Docker Compose: ``` -docker compose up -d --remove-orphans +# create shared network in docker +docker network create shared-network +# start running service with docker compose +make up +# stop running service with docker compose +make down ``` -## 2. Configure MinIO - -Set up MinIO buckets and access: - -### Configure MinIO client - -``` -mc alias set local http://localhost:9000 minioadmin minioadmin -``` - -### Create required buckets - -``` -mc mb local/vultiserver -mc mb local/vultiplugin -``` +## 2. Access MinIO You can verify the buckets were created by visiting the MinIO Console: - URL: http://localhost:9001 - Username: minioadmin - Password: minioadmin -## 3. Create Required Directories - -### Create directories for vault storage -``` -mkdir -p /tmp/vultisigner/server/vaults -mkdir -p /tmp/vultisigner/plugin/vaults -``` - -### Set appropriate permissions - -``` -sudo chmod 777 /tmp/vultisigner/server/vaults -sudo chmod 777 /tmp/vultisigner/plugin/vaults -``` - -## 4. Start Services - -Start the services in the following order, each one in a different terminal: - -### 4.1. Start Vultisigner Server - -``` -export VS_CONFIG_NAME=config-server -go run cmd/vultisigner/main.go -``` -### 4.2. Start Vultisigner Plugin - -``` -export VS_CONFIG_NAME=config-plugin -go run cmd/vultisigner/main.go -``` - -### 4.3. Start Server Worker - -``` -export VS_CONFIG_NAME=config-server -go run cmd/worker/main.go -``` - -### 4.4. Start Plugin Worker - -``` -export VS_CONFIG_NAME=config-plugin -go run cmd/worker/main.go -``` - -## 5 Run keyGen - -On a 5th terminal, run : - -``` -curl -X POST http://localhost:8081/vault/create \ --H "Content-Type: application/json" \ --d '{ - "name": "Server2Server-Vault", - "session_id": "650e8400-e29b-41d4-a716-446655440000", - "hex_encryption_key": "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef", - "hex_chain_code": "2023456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef", - "local_party_id": "2", - "encryption_password": "your-secure-password", - "email": "admin2@example.com", - "start_session": true, - "parties": ["1", "2"] -}' -``` -Then - -``` -curl -X POST http://localhost:8080/vault/create \ --H "Content-Type: application/json" \ --d '{ - "name": "Server2Server-Vault", - "session_id": "650e8400-e29b-41d4-a716-446655440000", - "hex_encryption_key": "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef", - "hex_chain_code": "2023456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef", - "local_party_id": "1", - "encryption_password": "your-secure-password", - "email": "admin@example.com", - "start_session": false -}' -``` - -## 6 Run keysign - -Once keyGen is done, you can start keysign. You have to replace the ecdsa key by the one appearing in the logs of the keygen. -``` -curl -X POST http://localhost:8081/vault/sign \ --H "Content-Type: application/json" \ --d @- << 'EOF' -{ - "public_key": "03b015e2ae364d8f6fff7f2b9fe1760a91e2d41c4a8e91c8750827cea4c3204e5d", - "messages": ["68656c6c6f"], - "session": "650e8400-e29b-41d4-a716-446655440000", - "hex_encryption_key": "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef", - "derive_path": "m/44'/0'/0'/0/0", - "is_ecdsa": true, - "vault_password": "your-secure-password" -} -EOF -``` - -Then - -``` -curl -X POST http://localhost:8080/vault/sign \ --H "Content-Type: application/json" \ --d @- << 'EOF' -{ - "public_key": "03b015e2ae364d8f6fff7f2b9fe1760a91e2d41c4a8e91c8750827cea4c3204e5d", - "messages": ["68656c6c6f"], - "session": "650e8400-e29b-41d4-a716-446655440000", - "hex_encryption_key": "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef", - "derive_path": "m/44'/0'/0'/0/0", - "is_ecdsa": true, - "vault_password": "your-secure-password" -} -EOF -``` - -# Restart everything : - -``` -docker compose down -docker compose up -d --remove-orphans -``` - -Restart all in order : - -``` -# Start servers -export VS_CONFIG_NAME=config-server -go run cmd/vultisigner/main.go - -export VS_CONFIG_NAME=config-plugin -go run cmd/vultisigner/main.go - -# Start workers -export VS_CONFIG_NAME=config-server -go run cmd/worker/main.go - -export VS_CONFIG_NAME=config-plugin -go run cmd/worker/main.go -``` - - - -## Verification - -To verify everything is running correctly: - -1. Check Docker containers: - -``` -docker ps -``` - -2. Verify MinIO buckets: -``` -mc ls local -``` - - - - - - -### 1. Start the required infrastructure - -- Postgres -- Redis -- MinIO (for faster development, buckets are auto created and configured during this step via `create_buckets.sh`) - -`make up` - -Verify the buckets were created by visiting the MinIO Console: -http://localhost:9001 (username: minioadmin, password: minioadmin) - - -### 2. Start the Verifier, Plugin and Marketplace - -Start each service in a different tab: - -Verifer - -```sh -make verifier-server -make verifier-worker -``` - -Plugin - -```sh -make plugin-server -make plugin-worker -``` - -Marketplace - -```sh - cd plugins-ui - npm ci - npm run dev -``` - -For a clean restart, run `make down` and restart the servers and workers (consider deleting the volumes and images for a fresh start) - - -### 3. Add new plugin listing and pricing in the Marketplace - -**Admin User** - -Create an admin user - -```sh - go run ./scripts/dev/create_verifier_admin/main.go -username=admin -password=supersecret -``` - -Log in to get an auth token, for subsequent requests: (`myauthtoken`) - -```sh -curl --location localhost:8080/login --request POST \ ---header 'Content-Type: application/json' \ ---data '{"username":"admin","password":"supersecret"}' -``` - -**Pricing** - -Create a pricing plan - -```sh -curl --location localhost:8080/pricings --request POST \ ---header 'Authorization: Bearer myauthtoken' \ ---header 'Content-Type: application/json' \ ---data '{ - "type": "FREE", - "amount": 0, - "metric": "FIXED" -}' -``` - -**Plugin Listing** - -Add new plugin listing - -```sh -curl --location localhost:8080/plugins --request POST \ ---header 'Authorization: Bearer myauthtoken' \ ---header 'Content-Type: application/json' \ ---data '{ - "title": "DCA Plugin", - "type": "dca", - "description": "Dollar cost averaging plugin automation", - "metadata": "{\"foo\": \"bar\"}", - "server_endpoint": "http://localhost:8081", - "pricing_id": "12345678-abcd-1234-5678-123456789abc" -}' -``` - - -### 4. Test the DCA Plugin execution - -#### 4.1 Create vault in production - -Create a 2-of-3 vault, allowing you to sign plugin policies using only two user devices and back up both device shares by exporting them from the Vultisig apps on each device. -Alternatively, for ease of testing, you can use the vault provided in the `test/test-2of2-vault-backups` folder and import the backups into the devices intended for use. - -#### 4.2 Import the vault into Vulticonnect - -Once imported into the devices, import the vault into Vulticonnect via the QR code displayed in the Vultisig app on one of the devices. This will enable you to sign plugin policies. - -#### 4.3 Bring the vault state into the local environment - -Since you are using a vault from production, there are additional steps required to bring in the missing production data locally. -- Rename each backup as `.bak` and import each into the corresponding local S3 folder (`vultisig-plugin`, `vultisig-verifier`) - -#### 4.4 Plugin installation (hack) - -As of now, there is no way to install a plugin that enables the "verifier" and "plugin" to be part of a user vault (DKLS resharing), which would allow them to meet the vault threshold and sign transactions without the need for the user to participate. -For local testing, we are using two shares from the user vault: first one for the "verifier" and the second one for the "plugin". As a result, there are some hardcoded values that should match the vault being used in Vulticonnect. -If you are using the vault provided in the `test/test-2of2-vault-backups` folder, the corresponding hardcoded values are already set. Otherwise, make sure that: - - `PluginPartyID` and `VerifierPartyID` (in common/util.go) match the vault participants (Vultisig app -> Vault settings -> Details). - - `vaultPassword` matches the vault password - - `hexEncryptionKey` matches the `hexChainCode` (execute `await window.vultisig.getVaults()` to get it) - -#### 4.5 Create a DCA policy through the UI - -The policy execution will start, so it is essential to ensure that the vault address has sufficient balance for the token and amount specified in the policy. - -```sh -export RPC_URL=http://127.0.0.1:8545 # from the local ethereum fork -export PRIVATE_KEY=ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 # from the local ethereum fork -export VAULT_ADDRESS=0x5582df2D22194AF8201997D750e80fd8140387c2 # from the vultisig app -``` - -Send some amount of native `ETH` to the vault address - -```sh - cast send $VAULT_ADDRESS --value 10ether --rpc-url $RPC_URL --private-key $PRIVATE_KEY -``` - -Mint some amount of the `ERC20` token used as a source in the policy. If `-token` is not present, the script will default to minting `WETH`. - -```sh - export TOKEN_ADDRESS=0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48 # USDC in this case - go run scripts/dev/mint_erc20/main.go -vault-address $VAULT_ADDRESS -token $TOKEN_ADDRESS -``` diff --git a/cmd/payroll/server/config.go b/cmd/payroll/server/config.go index 7cef1e4..ac5a859 100644 --- a/cmd/payroll/server/config.go +++ b/cmd/payroll/server/config.go @@ -3,6 +3,7 @@ package main import ( "fmt" "os" + "strings" "github.com/spf13/viper" "github.com/vultisig/verifier/vault_config" @@ -23,7 +24,6 @@ type PayrollServerConfig struct { Host string `mapstructure:"host" json:"host,omitempty"` Port string `mapstructure:"port" json:"port,omitempty"` } `mapstructure:"datadog" json:"datadog"` - EncryptionSecret string `mapstructure:"encryption_secret" json:"encryption_secret,omitempty"` } func GetConfigure() (*PayrollServerConfig, error) { @@ -38,6 +38,7 @@ func GetConfigure() (*PayrollServerConfig, error) { func ReadConfig(configName string) (*PayrollServerConfig, error) { viper.SetConfigName(configName) viper.AddConfigPath(".") + viper.SetEnvKeyReplacer(strings.NewReplacer(".", "_")) viper.AutomaticEnv() viper.SetDefault("Server.VaultsFilePath", "vaults") diff --git a/cmd/payroll/server/main.go b/cmd/payroll/server/main.go index 7d5037f..c12d8f1 100644 --- a/cmd/payroll/server/main.go +++ b/cmd/payroll/server/main.go @@ -71,7 +71,7 @@ func main() { if err != nil { logger.Fatalf("Failed to connect to database: %v", err) } - p, err := payroll.NewPayrollPlugin(db, vaultStorage, cfg.BaseConfigPath, txIndexerService, client, inspector, cfg.EncryptionSecret) + p, err := payroll.NewPayrollPlugin(db, vaultStorage, cfg.BaseConfigPath, txIndexerService, client, inspector, cfg.Server.EncryptionSecret) if err != nil { logger.Fatalf("failed to create payroll plugin,err: %s", err) } diff --git a/cmd/payroll/worker/config.go b/cmd/payroll/worker/config.go index f6b9afe..08b8265 100644 --- a/cmd/payroll/worker/config.go +++ b/cmd/payroll/worker/config.go @@ -3,6 +3,7 @@ package main import ( "fmt" "os" + "strings" "github.com/spf13/viper" "github.com/vultisig/verifier/vault_config" @@ -21,8 +22,7 @@ type PayrollWorkerConfig struct { Database struct { DSN string `mapstructure:"dsn" json:"dsn,omitempty"` } `mapstructure:"database" json:"database,omitempty"` - BaseConfigPath string `mapstructure:"base_file_path" json:"base_file_path,omitempty"` - EncryptionSecret string `mapstructure:"encryption_secret" json:"encryption_secret,omitempty"` + BaseConfigPath string `mapstructure:"base_file_path" json:"base_file_path,omitempty"` } func GetConfigure() (*PayrollWorkerConfig, error) { @@ -36,6 +36,7 @@ func GetConfigure() (*PayrollWorkerConfig, error) { func ReadConfig(configName string) (*PayrollWorkerConfig, error) { viper.SetConfigName(configName) viper.AddConfigPath(".") + viper.SetEnvKeyReplacer(strings.NewReplacer(".", "_")) viper.AutomaticEnv() if err := viper.ReadInConfig(); err != nil { diff --git a/cmd/payroll/worker/main.go b/cmd/payroll/worker/main.go index e381603..56c6a20 100644 --- a/cmd/payroll/worker/main.go +++ b/cmd/payroll/worker/main.go @@ -81,7 +81,7 @@ func main() { if err != nil { panic(fmt.Errorf("failed to create postgres backend: %w", err)) } - p, err := payroll.NewPayrollPlugin(postgressDB, vaultStorage, cfg.BaseConfigPath, txIndexerService, client, inspector, cfg.EncryptionSecret) + p, err := payroll.NewPayrollPlugin(postgressDB, vaultStorage, cfg.BaseConfigPath, txIndexerService, client, inspector, cfg.VaultServiceConfig.EncryptionSecret) if err != nil { panic(fmt.Errorf("failed to create payroll plugin: %w", err)) } diff --git a/config-server.yaml b/config-server.yaml deleted file mode 100644 index 626b745..0000000 --- a/config-server.yaml +++ /dev/null @@ -1,27 +0,0 @@ -server: - port: "8080" - host: "localhost" - vaults_file_path: "/tmp/vultisigner/server/vaults" - -database: - dsn: postgres://myuser:mypassword@localhost:5432/vultisig-plugin?sslmode=disable - -redis: - host: "localhost" - port: "6379" - password: "" - db: "0" - -block_storage: - type: "s3" - endpoint: "http://localhost:9000" - bucket: "vultiserver" - access_key: "minioadmin" - secret: "minioadmin" - region: "us-east-1" - host: "http://localhost:9000" - force_path_style: true - disable_ssl: true - -relay: - server: "https://api.vultisig.com/router" diff --git a/config-verifier.yaml b/config-verifier.yaml deleted file mode 100644 index 237df9a..0000000 --- a/config-verifier.yaml +++ /dev/null @@ -1,44 +0,0 @@ -# verifier - -server: - host: localhost - port: 8080 - vaults_file_path: /tmp/verifier/vaults - mode: verifier - plugin: - type: dca - -database: - dsn: postgres://myuser:mypassword@localhost:5432/vultisig-verifier?sslmode=disable - -plugin: - plugin_configs: - dca: - rpc_url: https://eth.llamarpc.com - uniswap: - v2_router: 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D - deadline: 5 # minutes - -relay: - server: https://api.vultisig.com/router - -redis: - host: localhost - port: 6379 - password: "" - db: 0 - -block_storage: - type: s3 - endpoint: http://localhost:9000 - bucket: vultisig-verifier - access_key: minioadmin - secret: minioadmin - region: us-east-1 - host: http://localhost:9000 - force_path_style: true - disable_ssl: true - -datadog: - host: localhost - port: 8125 diff --git a/config.example.json b/config.example.json deleted file mode 100644 index 5b58a07..0000000 --- a/config.example.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "server": { - "host": "localhost", - "port": 8080, - "jwt_secret": "secret" - }, - "redis": { - "host": "localhost", - "port": "6379" - }, - "block_storage_config": { - "host": "http://localhost:9000", - "region": "us-east-1", - "access_key": "minioadmin", - "secret": "minioadmin", - "bucket": "vultisig-verifier" - }, - "database": { - "dsn": "postgres://myuser:mypassword@localhost:5432/vultisig-verifier?sslmode=disable" - }, - "plugin": {}, - "datadog": { - "host": "localhost", - "port": "8125" - }, - "auth": { - "nonce_expiry_minutes": 15 - } -} diff --git a/create_buckets.sh b/create_buckets.sh index 8581293..c161017 100755 --- a/create_buckets.sh +++ b/create_buckets.sh @@ -5,7 +5,7 @@ sleep 5 mc alias set local http://localhost:9000 minioadmin minioadmin -buckets="vultisig-verifier vultisig-plugin" +buckets="vultisig-payroll vultisig-dca vultisig-fee" for bucket in $buckets; do mc mb --ignore-existing local/$bucket diff --git a/docker-compose.yaml b/docker-compose.yaml index 529dbef..ab2521a 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -1,52 +1,106 @@ services: - db: - build: - context: . - dockerfile: Dockerfile.postgres - container_name: postgres-db + payroll-db: + image: postgres:15 environment: POSTGRES_USER: myuser POSTGRES_PASSWORD: mypassword POSTGRES_DB: vultisig-plugin ports: - - "5432:5432" + - "5431:5432" volumes: - db_data:/var/lib/postgresql/data + - ./init-scripts:/docker-entrypoint-initdb.d + healthcheck: + test: [ "CMD", "pg_isready", "-U", "myuser" ] + interval: 1s + timeout: 5s + retries: 3 + networks: + - shared_network - redis: + redis-payroll: image: redis:latest - container_name: signer-redis ports: - - "6379:6379" - volumes: - - redis_data:/data + - "6378:6379" + networks: + - shared_network + healthcheck: + test: [ "CMD", "redis-cli", "ping" ] + interval: 1s + timeout: 5s + retries: 3 asynqmon: platform: linux/amd64 image: hibiken/asynqmon:latest - container_name: asynq-monitor ports: - "8181:8080" depends_on: - - redis + - redis-payroll - minio: - # image: minio/minio + minio-plugin: build: context: . dockerfile: Dockerfile.minio - container_name: signer-minio + platforms: + - linux/amd64 ports: - - "9000:9000" # s3 api - - "9090:9090" # console + - "9100:9000" # s3 api + - "9091:9090" # console environment: MINIO_ROOT_USER: minioadmin MINIO_ROOT_PASSWORD: minioadmin - command: server /data --console-address ":9090" volumes: - minio_data:/data + networks: + - shared_network + payroll-server: + build: + context: . + dockerfile: Dockerfile.Payroll.server + platforms: + - linux/amd64 + environment: + REDIS_HOST: redis-payroll + REDIS_PORT: 6379 + BLOCK_STORAGE_HOST: http://minio-plugin:9000 + DATABASE_DSN: postgres://myuser:mypassword@payroll-db:5432/vultisig-payroll?sslmode=disable + ports: + - "8081:8080" + depends_on: + payroll-db: + condition: service_healthy + redis-payroll: + condition: service_healthy + minio-plugin: + condition: service_started + networks: + - shared_network + worker: + build: + context: . + dockerfile: Dockerfile.Payroll.worker + platforms: + - linux/amd64 + environment: + REDIS_HOST: redis-payroll + REDIS_PORT: 6379 + BLOCK_STORAGE_HOST: http://minio-plugin:9000 + DATABASE_DSN: postgres://myuser:mypassword@payroll-db:5432/vultisig-payroll?sslmode=disable + depends_on: + payroll-db: + condition: service_healthy + redis-payroll: + condition: service_healthy + minio-plugin: + condition: service_started + networks: + - shared_network volumes: db_data: redis_data: minio_data: +networks: + shared_network: + external: true \ No newline at end of file diff --git a/init-scripts/01_create_vultisig_plugin.sql b/init-scripts/01_create_vultisig_plugin.sql index 7a969da..9f39f90 100644 --- a/init-scripts/01_create_vultisig_plugin.sql +++ b/init-scripts/01_create_vultisig_plugin.sql @@ -1 +1 @@ -CREATE DATABASE IF NOT EXISTS "vultisig-plugin"; \ No newline at end of file +CREATE DATABASE "vultisig-payroll"; \ No newline at end of file diff --git a/init-scripts/02_create_vultisig_verifier.sql b/init-scripts/02_create_vultisig_verifier.sql deleted file mode 100644 index 2099358..0000000 --- a/init-scripts/02_create_vultisig_verifier.sql +++ /dev/null @@ -1 +0,0 @@ -CREATE DATABASE IF NOT EXISTS "vultisig-verifier"; \ No newline at end of file diff --git a/payroll.server.example.json b/payroll.server.example.json new file mode 100644 index 0000000..0da9c63 --- /dev/null +++ b/payroll.server.example.json @@ -0,0 +1,27 @@ +{ + "server": { + "host": "localhost", + "port": 8080, + "encryption_secret": "test123" + }, + "database": { + "dsn": "postgres://myuser:mypassword@localhost:5431/vultisig-payroll?sslmode=disable" + }, + "base_config_path": "../../../etc/vultisig", + "redis": { + "host": "localhost", + "port": "6378", + "password": "password" + }, + "block_storage": { + "host": "http://localhost:9100", + "region": "us-east-1", + "access_key": "minioadmin", + "secret": "minioadmin", + "bucket": "vultisig-payroll" + }, + "datadog": { + "host": "localhost", + "port": 8125 + } +} diff --git a/payroll.worker.example.json b/payroll.worker.example.json new file mode 100644 index 0000000..5a0b021 --- /dev/null +++ b/payroll.worker.example.json @@ -0,0 +1,30 @@ +{ + "vault_service": { + "relay": { + "server": "https://api.vultisig.com/router" + }, + "local_party_prefix": "payroll-plugin-", + "queue_email_task": false, + "encryption_secret": "test123" + }, + "redis": { + "host": "localhost", + "port": "6378", + "password": "password" + }, + "block_storage": { + "host": "http://localhost:9100", + "region": "us-east-1", + "access_key": "minioadmin", + "secret": "minioadmin", + "bucket": "vultisig-payroll" + }, + "datadog": { + "host": "localhost", + "port": 8125 + }, + "base_file_path": "../../../etc/vultisig", + "database": { + "dsn": "postgres://myuser:mypassword@localhost:5431/vultisig-plugin?sslmode=disable" + } +}