Skip to content

Commit

Permalink
Merge pull request #329 from Lumerin-protocol/dev
Browse files Browse the repository at this point in the history
TEST-1.0.60 Update for versioning
  • Loading branch information
abs2023 authored Dec 3, 2024
2 parents 2da0f41 + d18a9bc commit ddd09ae
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 9 deletions.
4 changes: 2 additions & 2 deletions docs/04a-consumer-setup-source.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ Save the .env file and exit the editor
#### 4. Build and start the proxy-router
```bash
./build.sh
go run cmd/main.go
./bin/proxy-router
```
After the iniial setup, you can execute `git pull` to get the latest updates and re-run the `./build.sh` and `go run cmd/main.go` to update the proxy-router with the latest changes.
After the iniial setup, you can execute `git pull` to get the latest updates and re-run the `./build.sh` and `./bin/proxy-router` to update the proxy-router with the latest changes.

#### 5. Confirm that the build is successful and console should show similar to below after started (and listening on specified ports 8082 for Swagger API and 3333 for the proxy-router):

Expand Down
25 changes: 20 additions & 5 deletions proxy-router/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,23 +1,38 @@
# Stage 1: Build
FROM golang:1.22.3-alpine as builder

# Capture the Git tag and commit hash during build
ARG TAG_NAME
ARG COMMIT
ENV TAG_NAME=$TAG_NAME
ENV COMMIT=$COMMIT

WORKDIR /app
WORKDIR /app
COPY . .

RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 ./build.sh&& \
cp /bin/sh /app/sh && chmod +x /app/sh
# Build the Go binary (recommended for linux/amd64...for MacARM use buildx)
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 \
TAG_NAME=$TAG_NAME COMMIT=$COMMIT ./build.sh && \
cp /bin/sh /app/sh && chmod +x /app/sh

# Multiplatform Build Notes:
# to support both amd64 and arm64, use Docker’s Buildx to create a multi-architecture image
# docker buildx create --use
# docker buildx build --platform linux/amd64,linux/arm64 -t proxy-router:latest .

# Stage 2: Final Image
FROM scratch
WORKDIR /app

# Copy required files and binary
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=builder /app/bin/proxy-router /usr/bin/
# COPY --from=builder /usr/bin/dbus-launch /usr/bin/
# COPY --from=builder /app/.env /app/.env

# Optional Copy utilities from busybox image
# COPY --from=busybox /bin /bin
# COPY --from=busybox /lib /lib

SHELL ["/bin/sh", "-c"]
EXPOSE 3333 8082

ENTRYPOINT ["proxy-router"]
13 changes: 11 additions & 2 deletions proxy-router/build.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
#!/bin/sh

VERSION=${TAG_NAME:-0.1.0}
echo VERSION=$VERSION
# Check if TAG_NAME is set; if not, use the latest Git tag or fallback to 0.1.0
if [ -z "$TAG_NAME" ]; then
TAG_NAME=$(git describe --tags --abbrev=0 2>/dev/null || echo "0.1.0")
if [ "$TAG_NAME" = "0.1.0" ]; then
echo "Warning: No Git tags found. Defaulting to TAG_NAME=$TAG_NAME"
else
echo "Using latest Git tag: $TAG_NAME"
fi
fi

VERSION=$TAG_NAME
echo VERSION=$VERSION
# if commit is not set, use the latest commit
if [ -z "$COMMIT" ]; then
COMMIT=$(git rev-parse HEAD)
Expand Down

0 comments on commit ddd09ae

Please sign in to comment.