Skip to content

Commit 270d7c5

Browse files
committed
refactor: update Dockerfile and lps-env.sh to support prebuilt binaries
1 parent 87e2ff5 commit 270d7c5

File tree

4 files changed

+24
-34
lines changed

4 files changed

+24
-34
lines changed

docker-compose/local/docker-compose.lps.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@ services:
33
lps:
44
build:
55
context: ../../
6-
dockerfile: ${LPS_DOCKERFILE:-docker-compose/lps/Dockerfile}
6+
dockerfile: docker-compose/lps/Dockerfile
77
args:
88
UID: "${LPS_UID}"
99
COMMIT_HASH: "${COMMIT_HASH}"
1010
COMMIT_TAG: "${COMMIT_TAG}"
1111
TARGETARCH: "${LPS_DOCKER_ARCH}"
12+
USE_PREBUILT: "${LPS_USE_PREBUILT:-source}"
1213
image: lps:latest
1314
container_name: lps01
1415
environment:

docker-compose/local/lps-env.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,19 @@ if [[ "$OS_TYPE" == "Darwin" ]]; then
2424
# macOS
2525
echo "Running on macOS"
2626
SED_INPLACE=("sed" "-i" "")
27-
LPS_DOCKERFILE_DEFAULT="docker-compose/lps/Dockerfile.prebuilt"
27+
LPS_USE_PREBUILT_DEFAULT="prebuilt"
2828
elif [[ "$OS_TYPE" == "Linux" ]]; then
2929
# Assume Ubuntu or other Linux
3030
echo "Running on Linux"
3131
SED_INPLACE=("sed" "-i")
32-
LPS_DOCKERFILE_DEFAULT="docker-compose/lps/Dockerfile"
32+
LPS_USE_PREBUILT_DEFAULT="source"
3333
else
3434
echo "Unsupported OS: $OS_TYPE"
3535
exit 1
3636
fi
3737

38-
if [ -z "${LPS_DOCKERFILE}" ]; then
39-
export LPS_DOCKERFILE="$LPS_DOCKERFILE_DEFAULT"
38+
if [ -z "${LPS_USE_PREBUILT}" ]; then
39+
export LPS_USE_PREBUILT="$LPS_USE_PREBUILT_DEFAULT"
4040
fi
4141

4242
if [ -z "${LPS_DOCKER_ARCH}" ]; then
@@ -339,7 +339,7 @@ echo " DISCOVERY_ADDRESS: $DISCOVERY_ADDRESS"
339339

340340
docker compose --env-file "$ENV_FILE" up -d powpeg-pegin powpeg-pegout
341341

342-
if [ "$LPS_DOCKERFILE" = "docker-compose/lps/Dockerfile.prebuilt" ]; then
342+
if [ "$LPS_USE_PREBUILT" = "prebuilt" ]; then
343343
# Build LPS binary locally (cross-compile) to avoid Go segfault in Docker on Mac
344344
echo "Building LPS binary locally (cross-compile for linux/${LPS_DOCKER_ARCH})..."
345345
pushd ../../ > /dev/null

docker-compose/lps/Dockerfile

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
FROM --platform=linux/amd64 golang:1.23.8@sha256:e54daaadd35ebb90fc1404ecdc6eb7338ae13555f71a71856ad96976ae084e44 AS builder
1+
ARG USE_PREBUILT=source
2+
ARG TARGETARCH=amd64
3+
4+
# Builder stage for compiling from source
5+
FROM --platform=linux/${TARGETARCH} golang:1.23.8@sha256:e54daaadd35ebb90fc1404ecdc6eb7338ae13555f71a71856ad96976ae084e44 AS builder-source
26

37
ARG COMMIT_HASH
48
ARG COMMIT_TAG
@@ -19,9 +23,19 @@ RUN if [[ "$LPS_STAGE" != "regtest" ]]; \
1923
else make build; \
2024
fi
2125

22-
FROM --platform=linux/amd64 alpine:3.19.1@sha256:c5b1261d6d3e43071626931fc004f70149baeba2c8ec672bd4f27761f8e1ad6b
26+
# Builder stage for pre-built binary
27+
FROM --platform=linux/${TARGETARCH} alpine:3.19.1@sha256:c5b1261d6d3e43071626931fc004f70149baeba2c8ec672bd4f27761f8e1ad6b AS builder-prebuilt
28+
29+
WORKDIR /code
30+
COPY build/liquidity-provider-server /code/build/liquidity-provider-server
31+
32+
# Select the appropriate builder based on USE_PREBUILT arg
33+
FROM builder-${USE_PREBUILT} AS selected-builder
34+
35+
# Final stage
36+
FROM --platform=linux/${TARGETARCH} alpine:3.19.1@sha256:c5b1261d6d3e43071626931fc004f70149baeba2c8ec672bd4f27761f8e1ad6b
2337

24-
COPY --from=builder /code/build/liquidity-provider-server /usr/local/bin/liquidity-provider-server
38+
COPY --from=selected-builder /code/build/liquidity-provider-server /usr/local/bin/liquidity-provider-server
2539

2640
ARG HOME="/home/lps"
2741
RUN adduser -u 1000 --home="$HOME" lps -D lps

docker-compose/lps/Dockerfile.prebuilt

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)