Skip to content

Commit dc985b8

Browse files
committed
✨ cli image 2.6.1
1 parent d421cdb commit dc985b8

File tree

4 files changed

+43
-10
lines changed

4 files changed

+43
-10
lines changed

packaging/README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,14 @@ This acts as base image for building `hasura/graphql-engine` image.
2222
It is generally published with format `hasura/graphql-engine-base:<SHA256>.<OS>.<ARCH>` where
2323
- `<SHA256>` is the `sha256sum` of the dockerfile used to build the image
2424
- `OS` is the operating system. It could be any of these values: `ubuntu`
25-
- `ARCH` is the architecture. It could be any of these values: `amd64`, `arm64`
25+
- `ARCH` is the architecture. It could be any of these values: `amd64`, `arm64`
26+
- `OS` is the operating system. It could be any of these values: `debian`, `ubuntu`, `centos`
27+
- `ARCH` is the architecture. It could be any of these values: `amd64`, `arm64`
28+
29+
## Devfolio Specific
30+
31+
### How to publish images
32+
33+
```
34+
docker buildx build --build-arg BASE_IMAGE=hasura/graphql-engine:v2.6.1 --no-cache -t ghcr.io/devfolioco/graphql-engine:v0.2.6.1.cli-migrations-v3 --platform linux/amd64,linux/arm64 --push .
35+
```

packaging/cli-migrations/v3/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,5 @@ ENV HGE_BINARY=${HGE_BINARY}
3030

3131
ENTRYPOINT ["docker-entrypoint.sh"]
3232

33-
CMD $HGE_BINARY serve
33+
# CMD $HGE_BINARY serve
34+
# CMD ["graphql-engine", "serve"]

packaging/cli-migrations/v3/docker-entrypoint.sh

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ log() {
1111

1212
DEFAULT_MIGRATIONS_DIR="/hasura-migrations"
1313
DEFAULT_METADATA_DIR="/hasura-metadata"
14+
DEFAULT_SEEDS_DIR="/hasura-seeds"
1415
TEMP_PROJECT_DIR="/tmp/hasura-project"
1516

1617
if [ -z ${HGE_BINARY+x} ]; then
@@ -67,6 +68,27 @@ if [ -z ${HASURA_GRAPHQL_METADATA_DIR+x} ]; then
6768
HASURA_GRAPHQL_METADATA_DIR="$DEFAULT_METADATA_DIR"
6869
fi
6970

71+
# check if seeds directory is set, default otherwise
72+
if [ -z ${HASURA_GRAPHQL_SEEDS_DIR+x} ]; then
73+
log "migrations-startup" "env var HASURA_GRAPHQL_SEEDS_DIR is not set, defaulting to $DEFAULT_SEEDS_DIR"
74+
HASURA_GRAPHQL_SEEDS_DIR="$DEFAULT_SEEDS_DIR"
75+
fi
76+
77+
# apply migrations if the directory exist
78+
if [ -d "$HASURA_GRAPHQL_MIGRATIONS_DIR" ]; then
79+
log "migrations-apply" "applying migrations from $HASURA_GRAPHQL_MIGRATIONS_DIR"
80+
mkdir -p "$TEMP_PROJECT_DIR"
81+
cp -a "$HASURA_GRAPHQL_MIGRATIONS_DIR/." "$TEMP_PROJECT_DIR/migrations/"
82+
cd "$TEMP_PROJECT_DIR"
83+
echo "version: 3" > config.yaml
84+
echo "endpoint: http://localhost:$HASURA_GRAPHQL_MIGRATIONS_SERVER_PORT" >> config.yaml
85+
hasura-cli migrate apply --all-databases
86+
log "migrations-apply" "reloading metadata"
87+
hasura-cli metadata reload
88+
else
89+
log "migrations-apply" "directory $HASURA_GRAPHQL_MIGRATIONS_DIR does not exist, skipping migrations"
90+
fi
91+
7092
# apply metadata if the directory exist
7193
if [ -d "$HASURA_GRAPHQL_METADATA_DIR" ]; then
7294
rm -rf "TEMP_PROJECT_DIR"
@@ -82,19 +104,19 @@ else
82104
log "migrations-apply" "directory $HASURA_GRAPHQL_METADATA_DIR does not exist, skipping metadata"
83105
fi
84106

85-
# apply migrations if the directory exist
86-
if [ -d "$HASURA_GRAPHQL_MIGRATIONS_DIR" ]; then
87-
log "migrations-apply" "applying migrations from $HASURA_GRAPHQL_MIGRATIONS_DIR"
107+
# apply seeds if the directory exist
108+
if [ -d "$HASURA_GRAPHQL_SEEDS_DIR" ]; then
109+
log "seeds-apply" "applying seeds from $HASURA_GRAPHQL_SEEDS_DIR"
88110
mkdir -p "$TEMP_PROJECT_DIR"
89-
cp -a "$HASURA_GRAPHQL_MIGRATIONS_DIR/." "$TEMP_PROJECT_DIR/migrations/"
111+
cp -a "$HASURA_GRAPHQL_SEEDS_DIR/." "$TEMP_PROJECT_DIR/seeds/"
90112
cd "$TEMP_PROJECT_DIR"
91113
echo "version: 3" > config.yaml
92114
echo "endpoint: http://localhost:$HASURA_GRAPHQL_MIGRATIONS_SERVER_PORT" >> config.yaml
93-
hasura-cli migrate apply --all-databases
94-
log "migrations-apply" "reloading metadata"
95-
hasura-cli metadata reload
115+
hasura-cli seed apply --database-name default
116+
# log "seeds-apply" "reloading metadata"
117+
# hasura-cli metadata reload
96118
else
97-
log "migrations-apply" "directory $HASURA_GRAPHQL_MIGRATIONS_DIR does not exist, skipping migrations"
119+
log "seeds-apply" "directory $HASURA_GRAPHQL_SEEDS_DIR does not exist, skipping seeds"
98120
fi
99121

100122
# kill graphql engine that we started earlier
22 MB
Binary file not shown.

0 commit comments

Comments
 (0)