Skip to content

Commit

Permalink
added init container for singlestore
Browse files Browse the repository at this point in the history
  • Loading branch information
kirill-potapenkov authored and madsem committed Jun 6, 2024
1 parent 00d9c2f commit c37b565
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 30 deletions.
26 changes: 18 additions & 8 deletions src/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,35 @@ services:

singlestore:
platform: linux/amd64
build:
context: ./docker/singlestore
dockerfile: Dockerfile
image: ghcr.io/singlestore-labs/singlestoredb-dev:latest
volumes:
- singlestore_data:/data
restart: always
environment:
ROOT_PASSWORD: ${DB_USER:-root}
DB_NAME: ${DB_NAME:-phpdock}
DB_USER: ${DB_USER:-root}
DB_PASS: ${DB_PASS:-secret}
command: ["bash", "-c", "/usr/local/bin/replace_env_vars.sh"]
ROOT_PASSWORD: ${DB_PASS:-secret}
ports:
- 3306:3306
- 8080:8080
- 9000:9000
networks:
- phpdock

singlestore_init:
image: curlimages/curl
environment:
ROOT_PASSWORD: ${DB_PASS:-secret}
DB_NAME: ${DB_NAME:-phpdock}
DB_USER: ${DB_USER:-phpdock}
DB_PASS: ${DB_PASS:-secret}
depends_on:
singlestore:
condition: service_healthy
volumes:
- ./docker/singlestore/:/docker-entrypoint-initdb.d
entrypoint: /docker-entrypoint-initdb.d/docker-entrypoint.sh
networks:
- phpdock

mail:
platform: linux/amd64
image: mailhog/mailhog
Expand Down
15 changes: 0 additions & 15 deletions src/docker/singlestore/Dockerfile

This file was deleted.

16 changes: 16 additions & 0 deletions src/docker/singlestore/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env sh

set -e
set -u
set -o pipefail

url="root:${ROOT_PASSWORD}@singlestore:9000/api/v1/query/rows"
header="content-type: application/json"


curl -s -XPOST -H "$header" -d "{ \"sql\": \"CREATE DATABASE IF NOT EXISTS ${DB_NAME};\" }" $url
curl -s -XPOST -H "$header" -d "{ \"sql\": \"CREATE USER IF NOT EXISTS '${DB_USER}'@'%' IDENTIFIED BY '${DB_PASS}';\" }" $url
curl -s -XPOST -H "$header" -d "{ \"sql\": \"GRANT ALL PRIVILEGES ON ${DB_NAME}.* TO '${DB_USER}'@'%';\" }" $url
curl -s -XPOST -H "$header" -d "{ \"sql\": \"FLUSH PRIVILEGES;\" }" $url

echo "Done"
4 changes: 0 additions & 4 deletions src/docker/singlestore/init.sql

This file was deleted.

3 changes: 0 additions & 3 deletions src/docker/singlestore/replace_env_vars.sh

This file was deleted.

0 comments on commit c37b565

Please sign in to comment.