Enable codex_enable_api_debug_peers (#471) (#474)

- Enable codex_enable_api_debug_peers

 - Add NAT_IP_AUTO for Dist-Tests
This commit is contained in:
Slava 2023-07-10 16:15:06 +03:00 committed by GitHub
parent 711e5e09d1
commit 6dd7e55719
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 36 additions and 31 deletions

View File

@ -22,6 +22,10 @@ env:
DOCKER_FILE: docker/codex.Dockerfile
DOCKER_REPO: codexstorage/nim-codex
MAKE_PARALLEL: 4
NIMFLAGS: '-d:disableMarchNative -d:codex_enable_api_debug_peers=true'
NIMFLAGS_RELEASE: '-d:disableMarchNative'
NAT_IP_AUTO: true
NAT_IP_AUTO_RELEASE: false
jobs:
@ -57,6 +61,14 @@ jobs:
- name: Checkout
uses: actions/checkout@v3
- name: Docker - Variables
run: |
# Release
if [[ ${{ startsWith(github.ref, 'refs/tags/') }} == "true" ]]; then
echo "NIMFLAGS=${{ env.NIMFLAGS_RELEASE }}" >>$GITHUB_ENV
echo "NAT_IP_AUTO=${{ env.NAT_IP_AUTO_RELEASE }}" >>$GITHUB_ENV
fi
- name: Docker - Meta
id: meta
uses: docker/metadata-action@v4
@ -83,39 +95,17 @@ jobs:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Docker - Build and export to Docker
uses: docker/build-push-action@v4
with:
context: .
file: ${{ env.DOCKER_FILE }}
platforms: ${{ env.PLATFORM }}
build-args: |
MAKE_PARALLEL=${{ env.MAKE_PARALLEL }}
load: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Docker - Minify image
uses: kitabisa/docker-slim-action@v1
id: slim
env:
DSLIM_HTTP_PROBE: false
with:
target: ${{ steps.meta.outputs.tags }}
overwrite: true
- name: Docker - Show slim report
run: echo "${REPORT}" | jq -r
env:
REPORT: ${{ steps.slim.outputs.report }}
- name: Docker - Push to Docker registry
- name: Docker - Build and Push
uses: docker/build-push-action@v4
with:
context: .
file: ${{ env.DOCKER_FILE }}
platforms: ${{ env.PLATFORM }}
push: true
build-args: |
MAKE_PARALLEL=${{ env.MAKE_PARALLEL }}
NIMFLAGS=${{ env.NIMFLAGS }}
NAT_IP_AUTO=${{ env.NAT_IP_AUTO }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

View File

@ -31,7 +31,7 @@
It means that at the image run it will just run `codex` application without any arguments and we can pass them as a regular arguments, by overriding command
```shell
docker run codexstorage/nim-codex codex --api-bindaddr=0.0.0.0
docker run codexstorage/nim-codex codex --api-bindaddr=0.0.0.0 --api-port=8080
```
@ -39,6 +39,12 @@
We can configure Codex using [Environment variables](../README#environment-variables) and [docker-compose.yaml](docker-compose.yaml) file can be useful as an example.
We also added a temporary environment variable `NAT_IP_AUTO` to the entrypoint which is set as `false` for releases and ` true` for regular builds. That approach is useful for Dist-Tests.
```shell
# Disable NAT_IP_AUTO for regular builds
docker run -e NAT_IP_AUTO=false codexstorage/nim-codex
```
## Slim
1. Build the image using `docker build -t status-im/codexsetup:latest -f codex.Dockerfile ..`

View File

@ -3,14 +3,15 @@ ARG BUILDER=ubuntu:lunar-20230415
ARG IMAGE=${BUILDER}
ARG BUILD_HOME=/src
ARG MAKE_PARALLEL=${MAKE_PARALLEL:-4}
ARG MAKE_PARAMS=${MAKE_PARAMS:-NIM_PARAMS="-d:disableMarchNative"}
ARG NIMFLAGS="${NIMFLAGS:-"-d:disableMarchNative"}"
ARG APP_HOME=/codex
ARG NAT_IP_AUTO=${NAT_IP_AUTO:-false}
# Build
FROM ${BUILDER} AS builder
ARG BUILD_HOME
ARG MAKE_PARALLEL
ARG MAKE_PARAMS
ARG NIMFLAGS
RUN apt-get update && apt-get install -y git cmake curl make bash lcov build-essential nim
RUN echo 'export NIMBLE_DIR="${HOME}/.nimble"' >> "${HOME}/.bash_env"
@ -20,16 +21,18 @@ WORKDIR ${BUILD_HOME}
COPY . .
RUN make clean
RUN make -j ${MAKE_PARALLEL} update
RUN make -j ${MAKE_PARALLEL} ${MAKE_PARAMS}
RUN make -j ${MAKE_PARALLEL}
# Create
FROM ${IMAGE}
ARG BUILD_HOME
ARG APP_HOME
ARG NAT_IP_AUTO
WORKDIR ${APP_HOME}
COPY --from=builder ${BUILD_HOME}/build/codex /usr/local/bin
COPY --chmod=0755 docker/docker-entrypoint.sh /
RUN apt-get update && apt-get install -y libgomp1 bash && rm -rf /var/lib/apt/lists/*
ENV NAT_IP_AUTO=${NAT_IP_AUTO}
ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["codex"]

View File

@ -1,5 +1,11 @@
#!/bin/bash
# Parameters
if [[ "${NAT_IP_AUTO}" == "true" ]]; then
export CODEX_NAT=$(hostname --ip-address)
echo "Set CODEX_NAT: ${CODEX_NAT}"
fi
# Run
echo "Run Codex node"
exec "$@"