diff --git a/testnet/docker-compose.local.yml b/testnet/docker-compose.local.yml index 3205da76ee..6acf1355b9 100644 --- a/testnet/docker-compose.local.yml +++ b/testnet/docker-compose.local.yml @@ -19,11 +19,11 @@ services: dockerfile: ./dockerfiles/enclave.Dockerfile args: TESTMODE: true - # enclave-debug: - # image: "testnetobscuronet.azurecr.io/obscuronet/enclave_debug:latest" - # build: - # context: $ROOT_PATH - # dockerfile: ./dockerfiles/enclave.debug.Dockerfile +# enclave-debug: +# image: "testnetobscuronet.azurecr.io/obscuronet/enclave_debug:latest" +# build: +# context: $ROOT_PATH +# dockerfile: ./dockerfiles/enclave.debug.Dockerfile ten-scan: image: "testnetobscuronet.azurecr.io/obscuronet/tenscan:latest" build: @@ -38,7 +38,7 @@ services: image: "testnetobscuronet.azurecr.io/obscuronet/obscuro_gateway:latest" build: context: $ROOT_PATH - dockerfile: ./tools/walletextension/enclave.Dockerfile + dockerfile: ./tools/walletextension/Dockerfile faucet: image: "testnetobscuronet.azurecr.io/obscuronet/faucet:latest" build: diff --git a/testnet/launcher/gateway/docker.go b/testnet/launcher/gateway/docker.go index 0fe5a85c0e..b9dc38c397 100644 --- a/testnet/launcher/gateway/docker.go +++ b/testnet/launcher/gateway/docker.go @@ -24,7 +24,7 @@ func (n *DockerGateway) Start() error { fmt.Printf("Starting gateway with config: \n%s\n\n", litter.Sdump(*n.cfg)) cmds := []string{ - "ego", "run", "/home/ten/go-ten/tools/walletextension/main/main", + "/home/obscuro/go-obscuro/tools/walletextension/bin/wallet_extension_linux", "--host", "0.0.0.0", "--port", fmt.Sprintf("%d", n.cfg.gatewayHTTPPort), "--portWS", fmt.Sprintf("%d", n.cfg.gatewayWSPort), diff --git a/testnet/testnet-local-build_images.sh b/testnet/testnet-local-build_images.sh index 99c404a4fe..1b65be1a6e 100755 --- a/testnet/testnet-local-build_images.sh +++ b/testnet/testnet-local-build_images.sh @@ -50,7 +50,7 @@ command docker build -t testnetobscuronet.azurecr.io/obscuronet/enclave:latest - #command docker build -t testnetobscuronet.azurecr.io/obscuronet/enclave_debug:latest -f "${root_path}/dockerfiles/enclave.debug.Dockerfile" "${root_path}" & command docker build -t testnetobscuronet.azurecr.io/obscuronet/tenscan:latest -f "${tools_path}/tenscan/Dockerfile" "${root_path}" & command docker build -t testnetobscuronet.azurecr.io/obscuronet/faucet:latest -f "${tools_path}/faucet/Dockerfile" "${root_path}" & -#command docker build -t testnetobscuronet.azurecr.io/obscuronet/obscuro_gateway:latest -f "${tools_path}/walletextension/enclave.Dockerfile" "${root_path}" & +command docker build -t testnetobscuronet.azurecr.io/obscuronet/obscuro_gateway:latest -f "${tools_path}/walletextension/Dockerfile" "${root_path}" & wait diff --git a/tools/walletextension/Dockerfile b/tools/walletextension/Dockerfile new file mode 100644 index 0000000000..5a25543b06 --- /dev/null +++ b/tools/walletextension/Dockerfile @@ -0,0 +1,51 @@ +## Build Stages: +# system = prepares the "OS" by downloading required binaries +# get-dependencies = downloads the go modules using the prepared system +# build-wallet = copies over the source code and builds the binaries using a compiler cache +# final = copies over only the executables in an alpine image that doesn't have any additional load. + +FROM golang:1.22.1-alpine3.19 as system + +# set the base libs to build / run +RUN apk add build-base bash git +ENV CGO_ENABLED=1 +ARG TESTNET_TYPE + +# Standard build stage that initializes the go dependencies +FROM system as get-dependencies +# create the base directory +# setup container data structure +RUN mkdir -p /home/obscuro/go-obscuro + + +# Ensures container layer caching when dependencies are not changed +WORKDIR /home/obscuro/go-obscuro +COPY go.mod . +COPY go.sum . +RUN go mod download + +# Build stage that will create a wallet extension executable +FROM get-dependencies as build-wallet +# make sure the geth network code is available +COPY . /home/obscuro/go-obscuro + +# build the gateway executable +WORKDIR /home/obscuro/go-obscuro/tools/walletextension/main +RUN --mount=type=cache,target=/root/.cache/go-build \ + go build -o ../bin/wallet_extension_linux + +# Lightweight final build stage. Includes bare minimum to start wallet extension +FROM alpine:3.18 + +# copy over the gateway executable +COPY --from=build-wallet /home/obscuro/go-obscuro/tools/walletextension/bin /home/obscuro/go-obscuro/tools/walletextension/bin + +# copy over the .sql migration files +COPY --from=build-wallet /home/obscuro/go-obscuro/tools/walletextension/storage/database /home/obscuro/go-obscuro/tools/walletextension/storage/database + +# copy over the entrypoint script +COPY --from=build-wallet /home/obscuro/go-obscuro/tools/walletextension/entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh + +ENTRYPOINT ["/entrypoint.sh"] +