feliixx / mongoplayground

a simple sandbox to test and share MongoDB queries
https://mongoplayground.net
GNU Affero General Public License v3.0
179 stars 12 forks source link

Local Setup #148

Closed riteshf closed 2 years ago

riteshf commented 2 years ago

I'm new to golang and finding it difficult to setup mongoplayground locally.

I did COMPOSE_DOCKER_CLI_BUILD=1 DOCKER_BUILDKIT=1 docker-compose up --build I can see it running in my terminal, logs are coming, but unable to find the port at which it is running, is there anything I'm missing?

Questions ?

rickhg12hs commented 2 years ago

Just slightly more than a guess, but is 8080 the local port?

feliixx commented 2 years ago

Yes, the server is listenning on port 8080, so you can access it with this URL: http://localhost:8080

You don't have to change the config, it should work directly

riteshf commented 2 years ago

http://localhost:8080/ is not working for me, I did check that no other service is using this port as well.

is there a separate start command for bringing up the web?

feliixx commented 2 years ago

@riteshf, no it should work with just this command.

Can you post the logs you're getting ?

riteshf commented 2 years ago

Logs


➜  mongoplayground git:(dev) COMPOSE_DOCKER_CLI_BUILD=1 DOCKER_BUILDKIT=1 docker-compose up --build                  
Building web
[+] Building 2.3s (27/27) FINISHED                                                                                                                              
 => [internal] load build definition from Dockerfile                                                                                                       0.0s
 => => transferring dockerfile: 687B                                                                                                                       0.0s
 => [internal] load .dockerignore                                                                                                                          0.0s
 => => transferring context: 2B                                                                                                                            0.0s
 => [internal] load metadata for docker.io/library/alpine:3.16                                                                                             2.1s
 => [internal] load metadata for docker.io/library/golang:alpine3.16                                                                                       2.2s
 => [internal] load build context                                                                                                                          0.1s
 => => transferring context: 1.67MB                                                                                                                        0.1s
 => [esbuild 1/4] FROM docker.io/library/golang:alpine3.16@sha256:0eb08c89ab1b0c638a9fe2780f7ae3ab18f6ecda2c76b908e09eb8073912045d                         0.0s
 => [stage-2 1/6] FROM docker.io/library/alpine:3.16@sha256:bc41182d7ef5ffc53a40b044e725193bc10142a1243f395ee852a8d9730fc2ad                               0.0s
 => CACHED [stage-2 2/6] WORKDIR /app                                                                                                                      0.0s
 => CACHED [esbuild 2/4] WORKDIR /tools                                                                                                                    0.0s
 => CACHED [esbuild 3/4] RUN go install github.com/evanw/esbuild/cmd/esbuild@v0.14.11                                                                      0.0s
 => CACHED [esbuild 4/4] RUN mv /go/bin/esbuild .                                                                                                          0.0s
 => CACHED [builder  2/12] COPY --from=esbuild /tools/esbuild /usr/bin/                                                                                    0.0s
 => CACHED [builder  3/12] WORKDIR /app                                                                                                                    0.0s
 => CACHED [builder  4/12] COPY go.mod .                                                                                                                   0.0s
 => CACHED [builder  5/12] COPY go.sum .                                                                                                                   0.0s
 => CACHED [builder  6/12] RUN go mod download                                                                                                             0.0s
 => CACHED [builder  7/12] COPY internal/web ./internal/web                                                                                                0.0s
 => CACHED [builder  8/12] COPY bundle.sh .                                                                                                                0.0s
 => CACHED [builder  9/12] RUN ./bundle.sh                                                                                                                 0.0s
 => CACHED [builder 10/12] COPY main.go .                                                                                                                  0.0s
 => CACHED [builder 11/12] COPY internal/*.go ./internal/                                                                                                  0.0s
 => CACHED [builder 12/12] RUN --mount=type=cache,target=/root/.cache/go-build go build                                                                    0.0s
 => CACHED [stage-2 3/6] COPY --from=builder /app/mongoplayground /usr/bin/                                                                                0.0s
 => CACHED [stage-2 4/6] COPY config.json .                                                                                                                0.0s
 => CACHED [stage-2 5/6] RUN mkdir storage                                                                                                                 0.0s
 => CACHED [stage-2 6/6] RUN mkdir backups                                                                                                                 0.0s
 => exporting to image                                                                                                                                     0.0s
 => => exporting layers                                                                                                                                    0.0s
 => => writing image sha256:64e255134af0a27ca9213f72e8a18472f33dd5ad07416672b04c3c2239578ea8                                                               0.0s
 => => naming to docker.io/library/mongoplayground_web                                                                                                     0.0s
Creating mongoplayground_mongodb_1 ... done
Creating mongoplayground_web_1     ... done
Attaching to mongoplayground_mongodb_1, mongoplayground_web_1
mongodb_1  | {"t":{"$date":"2022-08-31T03:51:53.329+00:00"},"s":"I",  "c":"NETWORK",  "id":4915701, "ctx":"-","msg":"Initialized wire specification","attr":{"spec":{"incomingExternalClient":{"minWireVersion":0,"maxWireVersion":17},"incomingInternalClient":{"minWireVersion":0,"maxWireVersion":17},"outgoing":{"minWireVersion":6,"maxWireVersion":17},"isInternalClient":true}}}
mongodb_1  | {"t":{"$date":"2022-08-31T03:51:53.330+00:00"},"s":"I",  "c":"CONTROL",  "id":23285,   "ctx":"-","msg":"Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'"}
mongodb_1  | {"t":{"$date":"2022-08-31T03:51:53.331+00:00"},"s":"I",  "c":"NETWORK",  "id":4648601, "ctx":"main","msg":"Implicit TCP FastOpen unavailable. If TCP FastOpen is required, set tcpFastOpenServer, tcpFastOpenClient, and tcpFastOpenQueueSize."}
mongodb_1  | {"t":{"$date":"2022-08-31T03:51:53.332+00:00"},"s":"I",  "c":"REPL",     "id":5123008, "ctx":"main","msg":"Successfully registered PrimaryOnlyService","attr":{"service":"TenantMigrationDonorService","namespace":"config.tenantMigrationDonors"}}
mongodb_1  | {"t":{"$date":"2022-08-31T03:51:53.332+00:00"},"s":"I",  "c":"REPL",     "id":5123008, "ctx":"main","msg":"Successfully registered PrimaryOnlyService","attr":{"service":"TenantMigrationRecipientService","namespace":"config.tenantMigrationRecipients"}}
mongodb_1  | {"t":{"$date":"2022-08-31T03:51:53.332+00:00"},"s":"I",  "c":"REPL",     "id":5123008, "ctx":"main","msg":"Successfully registered PrimaryOnlyService","attr":{"service":"ShardSplitDonorService","namespace":"config.tenantSplitDonors"}}
mongodb_1  | {"t":{"$date":"2022-08-31T03:51:53.332+00:00"},"s":"I",  "c":"CONTROL",  "id":5945603, "ctx":"main","msg":"Multi threading initialized"}
mongodb_1  | {"t":{"$date":"2022-08-31T03:51:53.332+00:00"},"s":"I",  "c":"CONTROL",  "id":4615611, "ctx":"initandlisten","msg":"MongoDB starting","attr":{"pid":1,"port":27017,"dbPath":"/data/db","architecture":"64-bit","host":"docker-desktop"}}
mongodb_1  | {"t":{"$date":"2022-08-31T03:51:53.332+00:00"},"s":"I",  "c":"CONTROL",  "id":23403,   "ctx":"initandlisten","msg":"Build Info","attr":{"buildInfo":{"version":"6.0.1","gitVersion":"32f0f9c88dc44a2c8073a5bd47cf779d4bfdee6b","openSSLVersion":"OpenSSL 1.1.1f  31 Mar 2020","modules":[],"allocator":"tcmalloc","environment":{"distmod":"ubuntu2004","distarch":"aarch64","target_arch":"aarch64"}}}}
mongodb_1  | {"t":{"$date":"2022-08-31T03:51:53.332+00:00"},"s":"I",  "c":"CONTROL",  "id":51765,   "ctx":"initandlisten","msg":"Operating System","attr":{"os":{"name":"Ubuntu","version":"20.04"}}}
mongodb_1  | {"t":{"$date":"2022-08-31T03:51:53.332+00:00"},"s":"I",  "c":"CONTROL",  "id":21951,   "ctx":"initandlisten","msg":"Options set by command line","attr":{"options":{"net":{"bindIp":"*"}}}}
mongodb_1  | {"t":{"$date":"2022-08-31T03:51:53.333+00:00"},"s":"I",  "c":"STORAGE",  "id":22297,   "ctx":"initandlisten","msg":"Using the XFS filesystem is strongly recommended with the WiredTiger storage engine. See http://dochub.mongodb.org/core/prodnotes-filesystem","tags":["startupWarnings"]}
mongodb_1  | {"t":{"$date":"2022-08-31T03:51:53.333+00:00"},"s":"I",  "c":"STORAGE",  "id":22315,   "ctx":"initandlisten","msg":"Opening WiredTiger","attr":{"config":"create,cache_size=3413M,session_max=33000,eviction=(threads_min=4,threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,remove=true,path=journal,compressor=snappy),builtin_extension_config=(zstd=(compression_level=6)),file_manager=(close_idle_time=600,close_scan_interval=10,close_handle_minimum=2000),statistics_log=(wait=0),json_output=(error,message),verbose=[recovery_progress:1,checkpoint_progress:1,compact_progress:1,backup:0,checkpoint:0,compact:0,evict:0,history_store:0,recovery:0,rts:0,salvage:0,tiered:0,timestamp:0,transaction:0,verify:0,log:0],"}}
web_1      | badger 2022/08/31 03:51:53 INFO: All 0 tables opened in 0s
mongodb_1  | {"t":{"$date":"2022-08-31T03:51:54.036+00:00"},"s":"I",  "c":"STORAGE",  "id":4795906, "ctx":"initandlisten","msg":"WiredTiger opened","attr":{"durationMillis":703}}
mongodb_1  | {"t":{"$date":"2022-08-31T03:51:54.036+00:00"},"s":"I",  "c":"RECOVERY", "id":23987,   "ctx":"initandlisten","msg":"WiredTiger recoveryTimestamp","attr":{"recoveryTimestamp":{"$timestamp":{"t":0,"i":0}}}}
mongodb_1  | {"t":{"$date":"2022-08-31T03:51:54.047+00:00"},"s":"I",  "c":"WT",       "id":4366408, "ctx":"initandlisten","msg":"No table logging settings modifications are required for existing WiredTiger tables","attr":{"loggingEnabled":true}}
mongodb_1  | {"t":{"$date":"2022-08-31T03:51:54.054+00:00"},"s":"W",  "c":"CONTROL",  "id":22120,   "ctx":"initandlisten","msg":"Access control is not enabled for the database. Read and write access to data and configuration is unrestricted","tags":["startupWarnings"]}
mongodb_1  | {"t":{"$date":"2022-08-31T03:51:54.055+00:00"},"s":"W",  "c":"CONTROL",  "id":5123300, "ctx":"initandlisten","msg":"vm.max_map_count is too low","attr":{"currentValue":262144,"recommendedMinimum":1677720,"maxConns":838860},"tags":["startupWarnings"]}
mongodb_1  | {"t":{"$date":"2022-08-31T03:51:54.055+00:00"},"s":"I",  "c":"STORAGE",  "id":20320,   "ctx":"initandlisten","msg":"createCollection","attr":{"namespace":"admin.system.version","uuidDisposition":"provided","uuid":{"uuid":{"$uuid":"f059cf0a-314f-4527-a83f-c9e771c0b058"}},"options":{"uuid":{"$uuid":"f059cf0a-314f-4527-a83f-c9e771c0b058"}}}}
mongodb_1  | {"t":{"$date":"2022-08-31T03:51:54.063+00:00"},"s":"I",  "c":"INDEX",    "id":20345,   "ctx":"initandlisten","msg":"Index build: done building","attr":{"buildUUID":null,"collectionUUID":{"uuid":{"$uuid":"f059cf0a-314f-4527-a83f-c9e771c0b058"}},"namespace":"admin.system.version","index":"_id_","ident":"index-1--8040110534236404039","collectionIdent":"collection-0--8040110534236404039","commitTimestamp":null}}
mongodb_1  | {"t":{"$date":"2022-08-31T03:51:54.063+00:00"},"s":"I",  "c":"REPL",     "id":20459,   "ctx":"initandlisten","msg":"Setting featureCompatibilityVersion","attr":{"newVersion":"6.0"}}
mongodb_1  | {"t":{"$date":"2022-08-31T03:51:54.063+00:00"},"s":"I",  "c":"REPL",     "id":5853300, "ctx":"initandlisten","msg":"current featureCompatibilityVersion value","attr":{"featureCompatibilityVersion":"6.0","context":"setFCV"}}
mongodb_1  | {"t":{"$date":"2022-08-31T03:51:54.063+00:00"},"s":"I",  "c":"NETWORK",  "id":4915702, "ctx":"initandlisten","msg":"Updated wire specification","attr":{"oldSpec":{"incomingExternalClient":{"minWireVersion":0,"maxWireVersion":17},"incomingInternalClient":{"minWireVersion":0,"maxWireVersion":17},"outgoing":{"minWireVersion":6,"maxWireVersion":17},"isInternalClient":true},"newSpec":{"incomingExternalClient":{"minWireVersion":0,"maxWireVersion":17},"incomingInternalClient":{"minWireVersion":17,"maxWireVersion":17},"outgoing":{"minWireVersion":17,"maxWireVersion":17},"isInternalClient":true}}}
mongodb_1  | {"t":{"$date":"2022-08-31T03:51:54.063+00:00"},"s":"I",  "c":"NETWORK",  "id":4915702, "ctx":"initandlisten","msg":"Updated wire specification","attr":{"oldSpec":{"incomingExternalClient":{"minWireVersion":0,"maxWireVersion":17},"incomingInternalClient":{"minWireVersion":17,"maxWireVersion":17},"outgoing":{"minWireVersion":17,"maxWireVersion":17},"isInternalClient":true},"newSpec":{"incomingExternalClient":{"minWireVersion":0,"maxWireVersion":17},"incomingInternalClient":{"minWireVersion":17,"maxWireVersion":17},"outgoing":{"minWireVersion":17,"maxWireVersion":17},"isInternalClient":true}}}
mongodb_1  | {"t":{"$date":"2022-08-31T03:51:54.063+00:00"},"s":"I",  "c":"REPL",     "id":5853300, "ctx":"initandlisten","msg":"current featureCompatibilityVersion value","attr":{"featureCompatibilityVersion":"6.0","context":"startup"}}
mongodb_1  | {"t":{"$date":"2022-08-31T03:51:54.064+00:00"},"s":"I",  "c":"STORAGE",  "id":5071100, "ctx":"initandlisten","msg":"Clearing temp directory"}
mongodb_1  | {"t":{"$date":"2022-08-31T03:51:54.064+00:00"},"s":"I",  "c":"CONTROL",  "id":20536,   "ctx":"initandlisten","msg":"Flow Control is enabled on this deployment"}
mongodb_1  | {"t":{"$date":"2022-08-31T03:51:54.064+00:00"},"s":"I",  "c":"FTDC",     "id":20625,   "ctx":"initandlisten","msg":"Initializing full-time diagnostic data capture","attr":{"dataDirectory":"/data/db/diagnostic.data"}}
mongodb_1  | {"t":{"$date":"2022-08-31T03:51:54.065+00:00"},"s":"I",  "c":"STORAGE",  "id":20320,   "ctx":"initandlisten","msg":"createCollection","attr":{"namespace":"local.startup_log","uuidDisposition":"generated","uuid":{"uuid":{"$uuid":"610187e1-1b1e-41b1-b564-acc6ba4a3b43"}},"options":{"capped":true,"size":10485760}}}
mongodb_1  | {"t":{"$date":"2022-08-31T03:51:54.074+00:00"},"s":"I",  "c":"INDEX",    "id":20345,   "ctx":"initandlisten","msg":"Index build: done building","attr":{"buildUUID":null,"collectionUUID":{"uuid":{"$uuid":"610187e1-1b1e-41b1-b564-acc6ba4a3b43"}},"namespace":"local.startup_log","index":"_id_","ident":"index-3--8040110534236404039","collectionIdent":"collection-2--8040110534236404039","commitTimestamp":null}}
mongodb_1  | {"t":{"$date":"2022-08-31T03:51:54.075+00:00"},"s":"I",  "c":"REPL",     "id":6015317, "ctx":"initandlisten","msg":"Setting new configuration state","attr":{"newState":"ConfigReplicationDisabled","oldState":"ConfigPreStart"}}
mongodb_1  | {"t":{"$date":"2022-08-31T03:51:54.075+00:00"},"s":"I",  "c":"STORAGE",  "id":22262,   "ctx":"initandlisten","msg":"Timestamp monitor starting"}
mongodb_1  | {"t":{"$date":"2022-08-31T03:51:54.079+00:00"},"s":"I",  "c":"STORAGE",  "id":20320,   "ctx":"LogicalSessionCacheRefresh","msg":"createCollection","attr":{"namespace":"config.system.sessions","uuidDisposition":"generated","uuid":{"uuid":{"$uuid":"d3f25906-f8d3-40dc-af0f-45395f9a509a"}},"options":{}}}
mongodb_1  | {"t":{"$date":"2022-08-31T03:51:54.079+00:00"},"s":"I",  "c":"NETWORK",  "id":23015,   "ctx":"listener","msg":"Listening on","attr":{"address":"/tmp/mongodb-27017.sock"}}
mongodb_1  | {"t":{"$date":"2022-08-31T03:51:54.079+00:00"},"s":"I",  "c":"NETWORK",  "id":23015,   "ctx":"listener","msg":"Listening on","attr":{"address":"0.0.0.0"}}
mongodb_1  | {"t":{"$date":"2022-08-31T03:51:54.079+00:00"},"s":"I",  "c":"NETWORK",  "id":23016,   "ctx":"listener","msg":"Waiting for connections","attr":{"port":27017,"ssl":"off"}}
mongodb_1  | {"t":{"$date":"2022-08-31T03:51:54.080+00:00"},"s":"I",  "c":"CONTROL",  "id":20712,   "ctx":"LogicalSessionCacheReap","msg":"Sessions collection is not set up; waiting until next sessions reap interval","attr":{"error":"NamespaceNotFound: config.system.sessions does not exist"}}
mongodb_1  | {"t":{"$date":"2022-08-31T03:51:54.115+00:00"},"s":"I",  "c":"INDEX",    "id":20345,   "ctx":"LogicalSessionCacheRefresh","msg":"Index build: done building","attr":{"buildUUID":null,"collectionUUID":{"uuid":{"$uuid":"d3f25906-f8d3-40dc-af0f-45395f9a509a"}},"namespace":"config.system.sessions","index":"_id_","ident":"index-5--8040110534236404039","collectionIdent":"collection-4--8040110534236404039","commitTimestamp":null}}
mongodb_1  | {"t":{"$date":"2022-08-31T03:51:54.115+00:00"},"s":"I",  "c":"INDEX",    "id":20345,   "ctx":"LogicalSessionCacheRefresh","msg":"Index build: done building","attr":{"buildUUID":null,"collectionUUID":{"uuid":{"$uuid":"d3f25906-f8d3-40dc-af0f-45395f9a509a"}},"namespace":"config.system.sessions","index":"lsidTTLIndex","ident":"index-6--8040110534236404039","collectionIdent":"collection-4--8040110534236404039","commitTimestamp":null}}
mongodb_1  | {"t":{"$date":"2022-08-31T03:51:54.473+00:00"},"s":"I",  "c":"NETWORK",  "id":22943,   "ctx":"listener","msg":"Connection accepted","attr":{"remote":"127.0.0.1:60412","uuid":"26c594d6-1d80-4613-b79b-05f878ac8db4","connectionId":1,"connectionCount":1}}
mongodb_1  | {"t":{"$date":"2022-08-31T03:51:54.473+00:00"},"s":"I",  "c":"NETWORK",  "id":51800,   "ctx":"conn1","msg":"client metadata","attr":{"remote":"127.0.0.1:60412","client":"conn1","doc":{"driver":{"name":"mongo-go-driver","version":"v1.10.0"},"os":{"type":"linux","architecture":"arm64"},"platform":"go1.19"}}}
mongodb_1  | {"t":{"$date":"2022-08-31T03:51:54.490+00:00"},"s":"I",  "c":"NETWORK",  "id":22943,   "ctx":"listener","msg":"Connection accepted","attr":{"remote":"127.0.0.1:60416","uuid":"2c341d81-6fe6-431f-bdc7-e59ce62ea011","connectionId":2,"connectionCount":2}}
mongodb_1  | {"t":{"$date":"2022-08-31T03:51:54.491+00:00"},"s":"I",  "c":"NETWORK",  "id":51800,   "ctx":"conn2","msg":"client metadata","attr":{"remote":"127.0.0.1:60416","client":"conn2","doc":{"driver":{"name":"mongo-go-driver","version":"v1.10.0"},"os":{"type":"linux","architecture":"arm64"},"platform":"go1.19"}}}
mongodb_1  | {"t":{"$date":"2022-08-31T03:52:03.473+00:00"},"s":"I",  "c":"NETWORK",  "id":22943,   "ctx":"listener","msg":"Connection accepted","attr":{"remote":"127.0.0.1:60420","uuid":"cfe4e4db-87d6-4bd1-9713-af65148a1d2e","connectionId":3,"connectionCount":3}}
mongodb_1  | {"t":{"$date":"2022-08-31T03:52:03.487+00:00"},"s":"I",  "c":"NETWORK",  "id":51800,   "ctx":"conn3","msg":"client metadata","attr":{"remote":"127.0.0.1:60420","client":"conn3","doc":{"driver":{"name":"mongo-go-driver","version":"v1.10.0"},"os":{"type":"linux","architecture":"arm64"},"platform":"go1.19"}}}
feliixx commented 2 years ago

everything looks fine.

Are you on windows ? If yes, it might be that docker is running in a separate VM that has a specific IP address. You may find it with the command one of those command:

If it still doesn't work, the easiest way is to just build the source and run the executable:

go build
./mongoplayground 

but you'll need to have a mongod instance running locally, or to update mongo.uri in config.json if you're using an atlas cluster

masai-ops commented 2 years ago

I'm on macOS

go build
./mongoplayground 

This worked, and I was able to start locally.

Docker still doesn't work tough. I think it might be related to the MongoDB version, mongod is not working, but mongosh is working on my machine

Thanks