Skip to content

Commit d0b40cc

Browse files
authored
fix: add version info to RP Docker build (#415)
1 parent b467d0f commit d0b40cc

File tree

5 files changed

+24
-5
lines changed

5 files changed

+24
-5
lines changed

.github/workflows/release_docker.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ jobs:
4141
with:
4242
context: .
4343
file: ${{ matrix.dockerfile }}
44+
build-args: |
45+
VERSION=${{ github.ref_name }}
46+
COMMIT_SHA=${{ github.sha }}
4447
push: true
4548
tags: ${{ steps.meta.outputs.tags }}
4649
labels: ${{ steps.meta.outputs.labels }}

docker/docker-compose.dev.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ services:
102102
args:
103103
- NETWORK=dev
104104
- COMPUTE_MODE=cpu
105+
- VERSION=${VERSION}
106+
- COMMIT_SHA=${COMMIT_SHA}
105107
extra_hosts:
106108
- "localhost:host-gateway"
107109
volumes:

docker/resource-provider/Dockerfile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ ARG COMPUTE_MODE=gpu
33
FROM nvidia/cuda:12.0.1-cudnn8-devel-ubuntu22.04 AS base
44
WORKDIR /usr/src/app
55
ARG NETWORK=testnet
6+
ARG VERSION
7+
ARG COMMIT_SHA
68

79
# Default environment variables
810
ENV LOG_LEVEL=info
@@ -28,11 +30,11 @@ COPY . .
2830

2931
FROM base AS build-gpu
3032
RUN nvcc --version && nvcc --ptx -o ./pkg/resourceprovider/cudaminer/keccak.ptx ./pkg/resourceprovider/cudaminer/keccak.cu
31-
RUN go build -v --tags cuda
33+
RUN go build -v -tags cuda -ldflags="-X 'github.com/lilypad-tech/lilypad/pkg/system.Version=${VERSION}' -X 'github.com/lilypad-tech/lilypad/pkg/system.CommitSHA=${COMMIT_SHA}'"
3234
ENV DISABLE_POW=false
3335

3436
FROM base AS build-cpu
35-
RUN go build -v
37+
RUN go build -v -ldflags="-X 'github.com/lilypad-tech/lilypad/pkg/system.Version=${VERSION}' -X 'github.com/lilypad-tech/lilypad/pkg/system.CommitSHA=${COMMIT_SHA}'"
3638
ENV DISABLE_POW=true
3739

3840
FROM build-$COMPUTE_MODE AS final

docker/solver/Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ ARG network=dev
88

99
COPY . .
1010
RUN go mod download && go mod verify
11-
RUN go build -v .
11+
RUN go build -v -ldflags="-X 'github.com/lilypad-tech/lilypad/pkg/system.Version=${VERSION}' -X 'github.com/lilypad-tech/lilypad/pkg/system.CommitSHA=${COMMIT_SHA}'"
1212
RUN go install
1313

1414
RUN (curl -Ls --tlsv1.2 --proto "=https" --retry 3 https://cli.doppler.com/install.sh || wget -t 3 -qO- https://cli.doppler.com/install.sh) | sh
@@ -24,9 +24,9 @@ RUN echo "doppler run --command \"cloudflared tunnel run & lilypad solver --netw
2424
FROM base AS expose-local
2525
EXPOSE 8080
2626
RUN if [ "${network}" = "dev" ]; then \
27-
echo "lilypad solver --network $network" >> run; \
27+
echo "lilypad solver --network $network" >> run; \
2828
else \
29-
echo "doppler run -- lilypad solver --network $network" >> run; \
29+
echo "doppler run -- lilypad solver --network $network" >> run; \
3030
fi
3131

3232
FROM expose-$expose_via AS final

stack

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ function compose-init() {
2626
function compose-build() {
2727
load-local-env
2828
compose-env
29+
get-build-version
2930
docker compose -f ./docker/docker-compose.dev.yml build "$@"
3031
}
3132

@@ -53,6 +54,14 @@ function load-local-env() {
5354
done < .local.dev
5455
}
5556

57+
############################################################################
58+
# Get build version info
59+
############################################################################
60+
function get-build-version() {
61+
export VERSION=$(git rev-parse --abbrev-ref HEAD)
62+
export COMMIT_SHA=$(git rev-parse HEAD)
63+
}
64+
5665
############################################################################
5766
# chain
5867
############################################################################
@@ -274,11 +283,14 @@ function resource-provider() {
274283
}
275284

276285
function resource-provider-docker-build() {
286+
get-build-version
277287
docker build \
278288
-t resource-provider \
279289
-f ./docker/resource-provider/Dockerfile \
280290
--build-arg NETWORK=dev \
281291
--build-arg DISABLE_POW=true \
292+
--build-arg VERSION=${VERSION} \
293+
--build-arg COMMIT_SHA=${COMMIT_SHA} \
282294
.
283295
}
284296

0 commit comments

Comments
 (0)