Skip to content

Commit

Permalink
Merge pull request #187 from zond/johnpooch/add-docker
Browse files Browse the repository at this point in the history
Add Dockerfile and update README
  • Loading branch information
johnpooch authored Jun 3, 2024
2 parents cea6b5d + 33a95e7 commit 80af72e
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 8 deletions.
38 changes: 38 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Start with a base image containing golang runtime
FROM golang:1.20

# Downloading gcloud package
RUN curl https://dl.google.com/dl/cloudsdk/release/google-cloud-sdk.tar.gz > /tmp/google-cloud-sdk.tar.gz

# Installing the package
RUN mkdir -p /usr/local/gcloud \
&& tar -C /usr/local/gcloud -xvf /tmp/google-cloud-sdk.tar.gz \
&& /usr/local/gcloud/google-cloud-sdk/install.sh

# Install the gcloud component that includes the App Engine extension for Go.
RUN /usr/local/gcloud/google-cloud-sdk/bin/gcloud components install app-engine-go

# Add the gcloud command-line tool to your path.
ENV PATH $PATH:/usr/local/gcloud/google-cloud-sdk/bin

# # Run dev_appserver.py . from inside the repo
# RUN dev_appserver.py .

# Set the working directory in the container
WORKDIR /go/src/app

# Copy the current directory contents into the container at /go/src/app
COPY . .

# Remove Dockerfile to prevent issue with App Engine
RUN rm Dockerfile

# Expose port 8080 to the outside world
EXPOSE 8080

# Expose port 8000 to the outside world
EXPOSE 8000

# Start the process
CMD ["python3", "../../../usr/local/gcloud/google-cloud-sdk/bin/dev_appserver.py", "--host=0.0.0.0", "--admin_host=0.0.0.0", "."]

23 changes: 15 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ A regularly updated service running this code is available at [https://diplicity

To play, either be brave and use the auto generated HTML UI at [https://diplicity-engine.appspot.com/](https://diplicity-engine.appspot.com/), or use one of the client projects:

* [https://github.com/spamguy/dipl.io](https://github.com/spamguy/dipl.io)
* [https://github.com/zond/android-diplicity](https://github.com/zond/android-diplicity)
- [https://github.com/spamguy/dipl.io](https://github.com/spamguy/dipl.io)
- [https://github.com/zond/android-diplicity](https://github.com/zond/android-diplicity)

## Architecture

Expand All @@ -32,15 +32,24 @@ To enable exploration of the API for debugging, research by UI engineers or even

To enable debugging the JSON output in a browser, adding the query parameter `accept=application/json` will make the server output JSON even to a browser that claims to prefer `text/html`.

## Running locally using Docker (recommended)

- Download Docker
- Navigate to the root directory of this project
- Run `docker build --tag 'diplicity' .`
- Run `docker run -p 8080:8080 -p 8000:8000 diplicity`
- The API is now available on your machine at `localhost:8080`
- The Admin server is now available on your machine at `localhost:8000`

## Running locally

To run it locally

1. Clone this repo.
2. Install the [App Engine SDK for Go](https://cloud.google.com/appengine/docs/go/download).
4. Make sure your `$GOPATH` is set to something reasonable, like `$HOME/go`.
5. Run `dev_appserver.py .` in the checked out directory.
6. Run `curl -XPOST http://localhost:8080/_configure -d '{"FCMConf": {"ServerKey": SERVER_KEY_FROM_FCM}, "OAuth": {"ClientID": CLIENT_ID_FROM_GOOGLE_CLOUD_PROJECT, "Secret": SECRET_FROM_GOOGLE_CLOUD_PROJECT}, "SendGrid": {"APIKey": SEND_GRID_API_KEY}}'`.
3. Make sure your `$GOPATH` is set to something reasonable, like `$HOME/go`.
4. Run `dev_appserver.py .` in the checked out directory.
5. Run `curl -XPOST http://localhost:8080/_configure -d '{"FCMConf": {"ServerKey": SERVER_KEY_FROM_FCM}, "OAuth": {"ClientID": CLIENT_ID_FROM_GOOGLE_CLOUD_PROJECT, "Secret": SECRET_FROM_GOOGLE_CLOUD_PROJECT}, "SendGrid": {"APIKey": SEND_GRID_API_KEY}}'`.
- This isn't necessary to run the server per se, but `FCMConf` is necessary for FCM message sending, `OAuth` is necessary for non `fake-id` login, and `SendGrid` is necessary for email sending.

### Faking user ID
Expand All @@ -57,8 +66,6 @@ To run the tests

1. Start the local server with a `--clear_datastore` to avoid pre-test clutter and `--datastore_consistency_policy=consistent` to avoid eventual consistency. Since the tests don't wait around for consistency to be achieved, this simplifies writing the tests. Also, use `--require_indexes` so that you verify all the necessary indices are present in `app/index.yaml`. If you find indices for `Game` missing, update and run `go run tools/genindex.go`, for other entity types remove `app/index.yaml`, run `go run tools/genindex.go` and then run the tests without `--require_indexes` to let `dev_appserver.py` add missing indices as it comes across them. The reason `Game` indices are special is that they are built using composite indexes according to https://cloud.google.com/appengine/articles/indexselection.

```dev_appserver.py --require_indexes --skip_sdk_update_check=true --clear_datastore=true --datastore_consistency_policy=consistent .```
`dev_appserver.py --require_indexes --skip_sdk_update_check=true --clear_datastore=true --datastore_consistency_policy=consistent .`

2. Run `go test -v` in the `diptest` directory.


0 comments on commit 80af72e

Please sign in to comment.