mirror of
https://github.com/Xahau/xahau-web.git
synced 2026-08-23 11:00:51 +00:00
Update Dockerfile based on xahaud example config file.
This commit is contained in:
@@ -143,11 +143,11 @@ FROM --platform=$BUILDPLATFORM ${BASE_IMAGE} AS builder
|
||||
ARG REPO_URL
|
||||
ARG REPO_BRANCH
|
||||
ARG RELEASE_TYPE
|
||||
ARG BASE_DIR
|
||||
ARG TARGETPLATFORM
|
||||
ARG BUILDPLATFORM
|
||||
|
||||
ENV DEBIAN_FRONTEND=noninteractive \
|
||||
BASE_DIR=/build \
|
||||
CONAN2_DIR=/root/.conan2
|
||||
|
||||
# ~~~~ Install build dependencies ~~~~
|
||||
@@ -162,7 +162,7 @@ RUN set -ex; \
|
||||
&& rm -rf /var/lib/apt/lists/* \
|
||||
;; \
|
||||
*rhel*|*fedora*|*centos*|*rocky*|*alma*) \
|
||||
dnf install -y epel-release && dnf update -y && \
|
||||
dnf install -y config-manager epel-release && dnf update -y && \
|
||||
dnf config-manager --set-enabled crb -y && \
|
||||
dnf groupinstall -y "Development Tools" && \
|
||||
dnf install -y curl wget git ca-certificates cmake glibc-headers glibc-devel \
|
||||
@@ -230,14 +230,22 @@ RUN cp ${BASE_DIR}/xahaud/cfg/xahaud-example.cfg ${BASE_DIR}/xahaud.cfg && \
|
||||
cp ${BASE_DIR}/xahaud/cfg/validators-example.txt ${BASE_DIR}/validators-xahau.txt && \
|
||||
cp ${BASE_DIR}/xahaud/.build/rippled ${BASE_DIR}/rippled
|
||||
|
||||
|
||||
|
||||
# ~~~~ Copy the xahaud.cfg and validators-xahau.txt files into the host OS ~~~~
|
||||
FROM scratch AS export
|
||||
ARG BASE_DIR
|
||||
|
||||
COPY --from=builder ${BASE_DIR}/rippled /xahaud
|
||||
COPY --from=builder ${BASE_DIR}/xahaud.cfg /xahaud.cfg
|
||||
COPY --from=builder ${BASE_DIR}/validators-xahau.txt /validators-xahau.txt
|
||||
|
||||
# ~~~~ Create a Docker image with xahaud ~~~~
|
||||
|
||||
|
||||
# ~~~~ Create a Docker image with xahaud and configuration files ~~~~
|
||||
FROM ${BASE_IMAGE} AS runtime
|
||||
ARG BASE_DIR
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
# ~~~~ Install runtime dependencies ~~~~
|
||||
RUN set -ex; \
|
||||
@@ -245,38 +253,38 @@ RUN set -ex; \
|
||||
case " $ID $ID_LIKE " in \
|
||||
*debian*|*ubuntu*) \
|
||||
apt-get update && apt-get install -y -qq \
|
||||
libssl3 libsqlite3-0 \
|
||||
libssl3 libsqlite3-0 ca-certificates \
|
||||
&& update-ca-certificates \
|
||||
&& rm -rf /var/lib/apt/lists/* \
|
||||
;; \
|
||||
*rhel*|*fedora*|*centos*|*rocky*|*alma*) \
|
||||
dnf install -y openssl-libs sqlite-libs \
|
||||
&& dnf clean all \
|
||||
dnf install -y openssl-libs sqlite-libs ca-certificates \
|
||||
&& dnf clean all && update-ca-trust \
|
||||
;; \
|
||||
esac
|
||||
|
||||
# ~~~~ Copy built binary and configs from builder ~~~~
|
||||
COPY --from=builder ${BASE_DIR}/rippled /usr/local/bin/xahaud
|
||||
COPY --from=builder ${BASE_DIR}/xahaud.cfg /etc/xahaud/xahaud.cfg
|
||||
COPY --from=builder ${BASE_DIR}/validators-xahau.txt /etc/xahaud/validators-xahau.txt
|
||||
RUN mkdir -p /opt/xahaud/etc /opt/xahaud/bin /opt/xahaud/db /var/log/xahaud
|
||||
COPY --from=builder ${BASE_DIR}/rippled /opt/xahaud/bin/xahaud
|
||||
COPY --from=builder ${BASE_DIR}/xahaud.cfg /opt/xahaud/etc/xahaud.cfg
|
||||
COPY --from=builder ${BASE_DIR}/validators-xahau.txt /opt/xahaud/etc/validators-xahau.txt
|
||||
|
||||
# ~~~~ Copy required shared libraries from builder ~~~~
|
||||
# ~~~~ Create dicrectories and copy required shared libraries from builder ~~~~
|
||||
RUN --mount=type=bind,from=builder,source=/root/.conan2,target=/tmp/conan \
|
||||
find /tmp/conan -name "*.so*" -type f -exec cp {} /usr/local/lib/ \; && \
|
||||
ldconfig
|
||||
|
||||
# ~~~~ Set permissions and create directories ~~~~
|
||||
RUN chmod 755 /usr/local/bin/xahaud && \
|
||||
mkdir -p /var/lib/xahaud /var/log/xahaud && \
|
||||
chmod 755 /var/lib/xahaud /var/log/xahaud
|
||||
# ~~~~ Set permissions ~~~~
|
||||
RUN chmod -R 755 /opt/xahaud /var/log/xahaud
|
||||
|
||||
WORKDIR /var/lib/xahaud
|
||||
WORKDIR /opt/xahaud
|
||||
|
||||
# ~~~~ Expose ports ~~~~
|
||||
EXPOSE 5005 6006 51235
|
||||
EXPOSE 5009 6009 50051 21337 21338
|
||||
|
||||
# ~~~~ Run xahaud ~~~~
|
||||
ENTRYPOINT ["/usr/local/bin/xahaud"]
|
||||
CMD ["--conf", "/etc/xahaud/xahaud.cfg"]
|
||||
ENTRYPOINT ["/opt/xahaud/bin/xahaud"]
|
||||
CMD ["--conf", "/opt/xahaud/etc/xahaud.cfg"]
|
||||
```
|
||||
|
||||
The above "multistage" Dockerfile can be used to build xahaud by running:
|
||||
@@ -293,7 +301,11 @@ To run the multistage build file and create a new Docker image with xahaud and t
|
||||
|
||||
`docker buildx build --target runtime --load -t xahaud:latest .`
|
||||
|
||||
The resultant image can be viewed with: `docker images` and run with: `docker run --rm xahaud:latest`
|
||||
The resultant image can be viewed with: `docker images` and run with:
|
||||
|
||||
`docker run --rm -d --name xahaud -p 5009:5009 -p 6009:6009 -p 21337:21337 -v xahau-data:/var/lib/xahaud xahaud:latest`
|
||||
|
||||
In the above command, you can adjust the `-d` flag to toggle running in detached mode, the `-p xxxx:xxxx` flags which define the port mappings, the `--name xahaud` flag to change the container's name, and the `-v xahau-data:/var/lib/xahaud` flag to change where persistent data is stored on the underlying operating system. If running in detached mode, logs can be viewed with `docker logs -f xahaud`.
|
||||
|
||||
### Amnesiac Operating Systems
|
||||
|
||||
|
||||
Reference in New Issue
Block a user