Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ cli image 2.6.1 #2

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion packaging/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,14 @@ This acts as base image for building `hasura/graphql-engine` image.
It is generally published with format `hasura/graphql-engine-base:<SHA256>.<OS>.<ARCH>` where
- `<SHA256>` is the `sha256sum` of the dockerfile used to build the image
- `OS` is the operating system. It could be any of these values: `ubuntu`
- `ARCH` is the architecture. It could be any of these values: `amd64`, `arm64`
- `ARCH` is the architecture. It could be any of these values: `amd64`, `arm64`
- `OS` is the operating system. It could be any of these values: `debian`, `ubuntu`, `centos`
- `ARCH` is the architecture. It could be any of these values: `amd64`, `arm64`

## Devfolio Specific

### How to publish images

```
docker buildx build --build-arg BASE_IMAGE=hasura/graphql-engine:v2.20.1 --no-cache -t ghcr.io/devfolioco/graphql-engine:v2.20.1.cli-migrations-v3 --platform linux/amd64,linux/arm64 --push .
```
3 changes: 1 addition & 2 deletions packaging/cli-migrations/v3/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
cli-hasura-linux-amd64
manifest.yaml
manifest.yaml
7 changes: 5 additions & 2 deletions packaging/cli-migrations/v3/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
ARG BASE_IMAGE
FROM ${BASE_IMAGE}

ARG TARGETARCH

# yum update uses --nobest option to tackle https://github.com/hasura/graphql-engine-mono/issues/4096
RUN { apt-get update && apt-get install -y netcat; } \
|| { yum update -y --nobest && yum install -y nc; }
Expand All @@ -18,7 +20,7 @@ RUN mkdir -p /.hasura \
ENV HASURA_GRAPHQL_SHOW_UPDATE_NOTIFICATION=false

COPY docker-entrypoint.sh /bin/
COPY hasura-cli /bin/hasura-cli
COPY cli-hasura-linux-${TARGETARCH} /bin/hasura-cli

RUN chmod +x /bin/hasura-cli

Expand All @@ -30,4 +32,5 @@ ENV HGE_BINARY=${HGE_BINARY}

ENTRYPOINT ["docker-entrypoint.sh"]

CMD $HGE_BINARY serve
# CMD $HGE_BINARY serve
# CMD ["graphql-engine", "serve"]
Binary file not shown.
Binary file not shown.
38 changes: 30 additions & 8 deletions packaging/cli-migrations/v3/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ log() {

DEFAULT_MIGRATIONS_DIR="/hasura-migrations"
DEFAULT_METADATA_DIR="/hasura-metadata"
DEFAULT_SEEDS_DIR="/hasura-seeds"
TEMP_PROJECT_DIR="/tmp/hasura-project"

if [ -z ${HGE_BINARY+x} ]; then
Expand Down Expand Up @@ -67,6 +68,27 @@ if [ -z ${HASURA_GRAPHQL_METADATA_DIR+x} ]; then
HASURA_GRAPHQL_METADATA_DIR="$DEFAULT_METADATA_DIR"
fi

# check if seeds directory is set, default otherwise
if [ -z ${HASURA_GRAPHQL_SEEDS_DIR+x} ]; then
log "migrations-startup" "env var HASURA_GRAPHQL_SEEDS_DIR is not set, defaulting to $DEFAULT_SEEDS_DIR"
HASURA_GRAPHQL_SEEDS_DIR="$DEFAULT_SEEDS_DIR"
fi

# apply migrations if the directory exist
if [ -d "$HASURA_GRAPHQL_MIGRATIONS_DIR" ]; then
log "migrations-apply" "applying migrations from $HASURA_GRAPHQL_MIGRATIONS_DIR"
mkdir -p "$TEMP_PROJECT_DIR"
cp -a "$HASURA_GRAPHQL_MIGRATIONS_DIR/." "$TEMP_PROJECT_DIR/migrations/"
cd "$TEMP_PROJECT_DIR"
echo "version: 3" > config.yaml
echo "endpoint: http://localhost:$HASURA_GRAPHQL_MIGRATIONS_SERVER_PORT" >> config.yaml
hasura-cli migrate apply --all-databases
log "migrations-apply" "reloading metadata"
hasura-cli metadata reload
else
log "migrations-apply" "directory $HASURA_GRAPHQL_MIGRATIONS_DIR does not exist, skipping migrations"
fi

# apply metadata if the directory exist
if [ -d "$HASURA_GRAPHQL_METADATA_DIR" ]; then
rm -rf "TEMP_PROJECT_DIR"
Expand All @@ -82,19 +104,19 @@ else
log "migrations-apply" "directory $HASURA_GRAPHQL_METADATA_DIR does not exist, skipping metadata"
fi

# apply migrations if the directory exist
if [ -d "$HASURA_GRAPHQL_MIGRATIONS_DIR" ]; then
log "migrations-apply" "applying migrations from $HASURA_GRAPHQL_MIGRATIONS_DIR"
# apply seeds if the directory exist
if [ -d "$HASURA_GRAPHQL_SEEDS_DIR" ]; then
log "seeds-apply" "applying seeds from $HASURA_GRAPHQL_SEEDS_DIR"
mkdir -p "$TEMP_PROJECT_DIR"
cp -a "$HASURA_GRAPHQL_MIGRATIONS_DIR/." "$TEMP_PROJECT_DIR/migrations/"
cp -a "$HASURA_GRAPHQL_SEEDS_DIR/." "$TEMP_PROJECT_DIR/seeds/"
cd "$TEMP_PROJECT_DIR"
echo "version: 3" > config.yaml
echo "endpoint: http://localhost:$HASURA_GRAPHQL_MIGRATIONS_SERVER_PORT" >> config.yaml
hasura-cli migrate apply --all-databases
log "migrations-apply" "reloading metadata"
hasura-cli metadata reload
hasura-cli seed apply --database-name default
# log "seeds-apply" "reloading metadata"
# hasura-cli metadata reload
else
log "migrations-apply" "directory $HASURA_GRAPHQL_MIGRATIONS_DIR does not exist, skipping migrations"
log "seeds-apply" "directory $HASURA_GRAPHQL_SEEDS_DIR does not exist, skipping seeds"
fi

# kill graphql engine that we started earlier
Expand Down