This folder contains the different stacks. Please refer to the README of each of the stacks for more information on how to get started.
Unless stated otherwise in the stack specific READMEs, the following steps should generally apply:
-
Change to the stack directory:
cd $sub_directory_under_stacks # this varies per-stack cd homepage-web # for example
-
Check any prerequisites:
make check
-
(Optionally) Ensure relevant repos are up-to-date:
# optional # this will also clone any that are not yet cloned make pull
-
Start the stack:
make up
-
Stop and destroy the stack after you have completed testing/development:
# WARNING: this will remove local data from ephemeral databases, etc make clean
See Using make for additional make targets and other information on using make to work with the stacks.
We use make to allow quick/easy use of docker and docker-compose commands
with the correct setup (make sets the env vars that docker needs) for the given stack.
Some optional general make variables can be used:
-
make ... SERVICE=....By default, most make targets will act on all services (e.g.
make up), but you can limit the action to a given service if you specifySERVICEe.g.make up SERVICE=dp-api-routerSome targets will use
SERVICEas a prefix and act on all matching services. -
make ... ENABLE_MULTI=1Some make actions/targets will fail if SERVICE does not specify a single service, e.g.
make clean-imagewhereas if you setENABLE_MULTIit will act on more than one: e.g.make clean-image ENABLE_MULTI=1 -
there are some variables specific to
make logs, see below for those.
make psequivalent todocker-compose ps(show running containers)make ps-dockerequivalent todocker ps(show running containers)make configequivalent todocker-compose config(show single YAML describing the stack)make up/make downbring the container(s) (for the stack orSERVICE) up/downmake healthquery the health of each servicemake clone/make pull/make git-statusgit clone/pull/statusall apps used by this stackmake prepapply initialisation files against repos in this stack (e.g. patches to source or scripts to prep the repos)make list-reposshow the list of repos for the apps in the stack - used bymake clonemake list-servicesshow the list of all services/containersmake list-appsshow the list of apps (a subset of services that have a 'x-repo-url' field)make logs LOGS_TAIL=1 LOGS_TIMESTAMP=1 LOGS_NO_PREFIX=1show the logs for the matching services (optionally with tailing, timestamp and/or container-prefixed)make attachattach to a running container (i.e. get a shell)make cleanmake clean-image- remove container imagesmake refresha shortcut formake down clean-image upmake checkcomprisesmake check-config- check certain conditions are truemake check-env-vars- warn if your shell is setting some relevant env varsmake check-versions- warn if specific versions of expected apps are missing
This example will show how we can debug dp-identity-api when we run the auth stack.
- Replace the contents of the
Dockerfile.localfile (in thedp-identity-api) with the following code
FROM golang:1.21-bullseye AS base
ENV GOCACHE=/go/.go/cache GOPATH=/go/.go/path TZ=Europe/London
RUN GOBIN=/bin go install github.com/cespare/reflex@v0.3.1
RUN GOBIN=/bin go install github.com/go-delve/delve/cmd/dlv@latest
RUN PATH=$PATH:/bin
ENV PATH=$PATH
# Clean cache, as we want all modules in the container to be under /go/.go/path
RUN go clean -modcache
COPY . .
RUN go build -gcflags="all=-N -l" -o /go/server
ENTRYPOINT ["dlv", "--log", "--listen=:2345", "--headless=true", "--api-version=2", "--accept-multiclient", "exec", "./server"]- Change the
BuildTime,GitCommit,Versionvariables in thedp-identity-api/main.gofile and assign them a string literal value (for example"1"). - Remove the
commandsection of thedp-compose/v2/manifests/core-ons/dp-identity-api.ymlfile. - Expose the port on which the debugging server is running on by adding
- "2345:2345"(in this example is 2345) to the ports section of thedp-compose/v2/manifests/core-ons/dp-identity-api.ymlfile. - In IntelliJ IDE or Goland IDE open
dp-identity-apirepo and on the menu bar clickRun->Edit Configurations.... On the popup window in the top left corner click the+button and chooseGo Remote(the default port should be 2345). Put also a useful name next to theName:label. HitApplyandOk.
- Run the auth stack if it is not running already (make sure to remove dp-identity-api image first) or if you are already running it, run
make refresh SERVICE=dp-identity-api. - Put your breakpoints in the code that you want to debug.
- On the menu bar click
Run->Debug Name-that-you-chose.