Skip to content

Commit 6ed7ec1

Browse files
committed
✨ cli image 2.6.1
1 parent b4f8956 commit 6ed7ec1

4 files changed

Lines changed: 40 additions & 10 deletions

File tree

packaging/README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,12 @@ 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: `debian`, `ubuntu`, `centos`
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+
27+
## Devfolio Specific
28+
29+
### How to publish images
30+
31+
```
32+
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 .
33+
```

packaging/cli-migrations/v3/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ ENV HASURA_GRAPHQL_CLI_ENVIRONMENT=server-on-docker
2929

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

32-
CMD ["graphql-engine", "serve"]
32+
# 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
# Use 9691 port for running temporary instance.
@@ -62,6 +63,27 @@ if [ -z ${HASURA_GRAPHQL_METADATA_DIR+x} ]; then
6263
HASURA_GRAPHQL_METADATA_DIR="$DEFAULT_METADATA_DIR"
6364
fi
6465

66+
# check if seeds directory is set, default otherwise
67+
if [ -z ${HASURA_GRAPHQL_SEEDS_DIR+x} ]; then
68+
log "migrations-startup" "env var HASURA_GRAPHQL_SEEDS_DIR is not set, defaulting to $DEFAULT_SEEDS_DIR"
69+
HASURA_GRAPHQL_SEEDS_DIR="$DEFAULT_SEEDS_DIR"
70+
fi
71+
72+
# apply migrations if the directory exist
73+
if [ -d "$HASURA_GRAPHQL_MIGRATIONS_DIR" ]; then
74+
log "migrations-apply" "applying migrations from $HASURA_GRAPHQL_MIGRATIONS_DIR"
75+
mkdir -p "$TEMP_PROJECT_DIR"
76+
cp -a "$HASURA_GRAPHQL_MIGRATIONS_DIR/." "$TEMP_PROJECT_DIR/migrations/"
77+
cd "$TEMP_PROJECT_DIR"
78+
echo "version: 3" > config.yaml
79+
echo "endpoint: http://localhost:$HASURA_GRAPHQL_MIGRATIONS_SERVER_PORT" >> config.yaml
80+
hasura-cli migrate apply --all-databases
81+
log "migrations-apply" "reloading metadata"
82+
hasura-cli metadata reload
83+
else
84+
log "migrations-apply" "directory $HASURA_GRAPHQL_MIGRATIONS_DIR does not exist, skipping migrations"
85+
fi
86+
6587
# apply metadata if the directory exist
6688
if [ -d "$HASURA_GRAPHQL_METADATA_DIR" ]; then
6789
rm -rf "TEMP_PROJECT_DIR"
@@ -77,19 +99,19 @@ else
7799
log "migrations-apply" "directory $HASURA_GRAPHQL_METADATA_DIR does not exist, skipping metadata"
78100
fi
79101

80-
# apply migrations if the directory exist
81-
if [ -d "$HASURA_GRAPHQL_MIGRATIONS_DIR" ]; then
82-
log "migrations-apply" "applying migrations from $HASURA_GRAPHQL_MIGRATIONS_DIR"
102+
# apply seeds if the directory exist
103+
if [ -d "$HASURA_GRAPHQL_SEEDS_DIR" ]; then
104+
log "seeds-apply" "applying seeds from $HASURA_GRAPHQL_SEEDS_DIR"
83105
mkdir -p "$TEMP_PROJECT_DIR"
84-
cp -a "$HASURA_GRAPHQL_MIGRATIONS_DIR/." "$TEMP_PROJECT_DIR/migrations/"
106+
cp -a "$HASURA_GRAPHQL_SEEDS_DIR/." "$TEMP_PROJECT_DIR/seeds/"
85107
cd "$TEMP_PROJECT_DIR"
86108
echo "version: 3" > config.yaml
87109
echo "endpoint: http://localhost:$HASURA_GRAPHQL_MIGRATIONS_SERVER_PORT" >> config.yaml
88-
hasura-cli migrate apply --all-databases
89-
log "migrations-apply" "reloading metadata"
90-
hasura-cli metadata reload
110+
hasura-cli seed apply --database-name default
111+
# log "seeds-apply" "reloading metadata"
112+
# hasura-cli metadata reload
91113
else
92-
log "migrations-apply" "directory $HASURA_GRAPHQL_MIGRATIONS_DIR does not exist, skipping migrations"
114+
log "seeds-apply" "directory $HASURA_GRAPHQL_SEEDS_DIR does not exist, skipping seeds"
93115
fi
94116

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

0 commit comments

Comments
 (0)