Zufar Muhamadeev
Zufar Muhamadeev

Reputation: 3212

How to implement docker image with google cloud datastore emulator and java

I need to create test docker image with google cloud datastore emulator and java application. Java app use emulator to store test data. How should i create this image? Should i use FROM openjdk:8 or FROM google/cloud-sdk:latest?

Upvotes: 0

Views: 647

Answers (1)

brotich
brotich

Reputation: 447

this is the config i used to create a datastore emulator

FROM google/cloud-sdk:latest
ENV CLOUDSDK_CORE_PROJECT project-id

ENTRYPOINT ["gcloud", "beta", "emulators", "datastore", "start",\
            "--host-port", "0.0.0.0:8000", "--no-store-on-disk", \
            "--consistency=1" ]
EXPOSE 8000

build steps:

  1. Build the image using:

    docker build -t datastore-emulator:latest .
    
  2. start a docker container:

    docker run -p 8000:8000 datastore-emulator:latest
    

set the application to use the emulator using:

export DATASTORE_EMULATOR_HOST=localhost:8000

Upvotes: 2

Related Questions