Skip to content

Commit

Permalink
test with bucket storage
Browse files Browse the repository at this point in the history
  • Loading branch information
Sacramentix committed Jul 28, 2024
1 parent 5286e34 commit 51ed0b4
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 33 deletions.
68 changes: 36 additions & 32 deletions dockerfile.neo4j
Original file line number Diff line number Diff line change
Expand Up @@ -100,35 +100,39 @@ WORKDIR /project/
COPY --from=neo4j /startup/ /startup/

CMD \
cd /project/sql-dump-to-neo4j &&\
# Copy the GCP credential to GCP.json file from the ENV
echo $GCP_JSON > GCP.json &&\
# Connect to Google Cloud
gcloud auth activate-service-account --key-file=GCP.json &&\
# Start Neo4j in background
neo4j start &&\
# Build and run the dump parser with Node js
npm start &&\
# Login to docker hub
docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD &&\
# cd to start building a image for cloud run
cd / &&\
# Build the image for the current lang
docker build -f /project/serverless-docker/dockerfile.neo4j / --build-arg wiki_lang=${WIKI_LANG} -t sacramentix1225/${WIKI_LANG}wiki-graph &&\
# Push it to docker hub
docker push sacramentix1225/${WIKI_LANG}wiki-graph &&\
# Configure to push to GCR hub too
gcloud auth configure-docker europe-west9-docker.pkg.dev --quiet &&\
# Configure to push to GCR hub too
docker tag sacramentix1225/${WIKI_LANG}wiki-graph europe-west9-docker.pkg.dev/sixdegreesofwikiadventure/wiki-graph/${WIKI_LANG}wiki-graph &&\
# Push to GCR.io
docker push europe-west9-docker.pkg.dev/sixdegreesofwikiadventure/wiki-graph/${WIKI_LANG}wiki-graph &&\
# Create a new Google Cloud Run
gcloud run deploy ${WIKI_LANG}wiki-graph-serverless --image=europe-west9-docker.pkg.dev/sixdegreesofwikiadventure/wiki-graph/${WIKI_LANG}wiki-graph:latest \
--cpu=8 --max-instances=5 --memory=32Gi --port=8080 --allow-unauthenticated \
--execution-environment=gen2 \
--region=europe-west9 --project=sixdegreesofwikiadventure &&\
# Delete the Instance running this script
export INSTANCE_NAME=$(curl -X GET http://metadata.google.internal/computeMetadata/v1/instance/name -H 'Metadata-Flavor: Google') &&\
export INSTANCE_ZONE=$(curl -X GET http://metadata.google.internal/computeMetadata/v1/instance/zone -H 'Metadata-Flavor: Google') &&\
gcloud --quiet compute instances delete $INSTANCE_NAME --zone=$INSTANCE_ZONE
cd /project/sql-dump-to-neo4j &&\
# Copy the GCP credential to GCP.json file from the ENV
echo $GCP_JSON > GCP.json &&\
# Connect to Google Cloud
gcloud auth activate-service-account --key-file=GCP.json &&\
# Start Neo4j in background
neo4j start &&\
# Build and run the dump parser with Node js
npm start &&\
# Login to docker hub
docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD &&\
# cd to start building a image for cloud run
cd / &&\
# Build the image for the current lang
docker build -f /project/serverless-docker/dockerfile.neo4j / --build-arg wiki_lang=${WIKI_LANG} -t sacramentix1225/${WIKI_LANG}wiki-graph &&\
# Push it to docker hub
docker push sacramentix1225/${WIKI_LANG}wiki-graph &&\
# Configure to push to GCR hub too
gcloud auth configure-docker europe-west9-docker.pkg.dev --quiet &&\
# Push the content of $NEO4J_HOME/data to Google Cloud Storage
# Create the Google Cloud Storage bucket if it doesn't exist
gsutil ls gs://${WIKI_LANG}wiki-graph-data || gsutil mb gs://${WIKI_LANG}wiki-graph-data &&\
gsutil -m cp -r "${NEO4J_HOME}"/data gs://${WIKI_LANG}wiki-graph-data \
# Configure to push to GCR hub too
docker tag sacramentix1225/${WIKI_LANG}wiki-graph europe-west9-docker.pkg.dev/sixdegreesofwikiadventure/wiki-graph/${WIKI_LANG}wiki-graph &&\
# Push to GCR.io
docker push europe-west9-docker.pkg.dev/sixdegreesofwikiadventure/wiki-graph/${WIKI_LANG}wiki-graph &&\
# Create a new Google Cloud Run
gcloud run deploy ${WIKI_LANG}wiki-graph-serverless --image=europe-west9-docker.pkg.dev/sixdegreesofwikiadventure/wiki-graph/${WIKI_LANG}wiki-graph:latest \
--cpu=8 --max-instances=5 --memory=32Gi --port=8080 --allow-unauthenticated \
--execution-environment=gen2 \
--region=europe-west9 --project=sixdegreesofwikiadventure &&\
# Delete the Instance running this script
export INSTANCE_NAME=$(curl -X GET http://metadata.google.internal/computeMetadata/v1/instance/name -H 'Metadata-Flavor: Google') &&\
export INSTANCE_ZONE=$(curl -X GET http://metadata.google.internal/computeMetadata/v1/instance/zone -H 'Metadata-Flavor: Google') &&\
gcloud --quiet compute instances delete $INSTANCE_NAME --zone=$INSTANCE_ZONE
2 changes: 1 addition & 1 deletion serverless-docker/dockerfile.neo4j
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ WORKDIR /

RUN echo -e "\n"dbms.security.auth_enabled=false >> "${NEO4J_HOME}"/conf/neo4j.conf

COPY /data /data
# COPY /data /data

COPY /project/serverless-docker /project

Expand Down

0 comments on commit 51ed0b4

Please sign in to comment.