Skip to content

Commit fd9138c

Browse files
committed
feat: move ord to layer 1 ordinals dir
1 parent 779cad0 commit fd9138c

File tree

6 files changed

+238
-1
lines changed

6 files changed

+238
-1
lines changed

.github/workflows/ord.yaml renamed to .github/workflows/ordinals.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
#- name: ord-alpine
2323
# context: "./ord/alpine"
2424
- name: ord-ubuntu
25-
context: "./ord/ubuntu"
25+
context: "./layer1/ordinals/ord/ubuntu"
2626
steps:
2727
- name: Checkout
2828
uses: actions/checkout@v4

layer1/ordinals/ord/README.md

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# An Ordinals ORD Docker Image
2+
3+
This Docker image is built to run Bitcoin Core and ord.
4+
5+
# An Ordinals ORD Tags
6+
- `ord-alpine` ([ord/Dockerfile](https://github.com/geekwho-eth/docker-bitcoin-core/blob/master/ord/Dockerfile))
7+
8+
ord build by ordinals install.sh.
9+
10+
## Features
11+
12+
- Utilizes Alpine Linux for a lightweight base image.
13+
- Non-root user (`ord`) for enhanced security.
14+
- Automatic installation of required dependencies.
15+
- Includes `libevent` and `libzmq` for improved performance.
16+
- Supports configuration via `ord.yaml`.
17+
- Exposes port `8080` for HTTP communication.
18+
19+
## Usage
20+
21+
1. **Build Image**:
22+
23+
```bash
24+
docker build -t ord-alpine .
25+
```
26+
27+
2. **Run Bitcoin Core**:
28+
29+
```bash
30+
docker run -d --name ord-alpine \
31+
-v /path/to/:/home/ord/ \
32+
-p 8080:8080 \
33+
ord-alpine ord --config=/home/ord/ord.yaml --rpc-url=127.0.0.1:8332 server --http-port=8080
34+
```
35+
36+
3. **Environment Variables**:
37+
38+
- `UID`: User ID (default: `100`).
39+
- `GID`: Group ID (default: `101`).
40+
- `ORD_YAML`: Path to `ord.yaml` (default: `/home/ord/ord.yaml`).
41+
- `ORD_USER`: User name (default: `ord`).
42+
- `ORD_RPC_URL`: RPC URL (default: `127.0.0.1:8332`).
43+
44+
4. **Configuration**:
45+
46+
Modify `ord.yaml` as per your requirements.
47+
48+
5. **Access Web Interface**:
49+
50+
Open your browser and go to `http://localhost:8080`.
51+
52+
6. **Additional Information**:
53+
54+
- [Bitcoin Core Documentation](https://bitcoin.org/en/bitcoin-core/)
55+
- [Ordinals GitHub Repository](https://github.com/ordinals/ord)
56+
57+
## Maintenance
58+
59+
For any issues or feedback, please contact the maintainer:
60+
61+
- Maintainer: GeekWho
62+
63+
64+
## Version Information
65+
66+
- Docker Image Version: 1.0
67+
- Bitcoin Core Version: [Specify Version]
68+
69+
## License
70+
71+
[MIT License](../LICENSE)
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Build stage for builder
2+
FROM alpine as builder
3+
4+
RUN sed -i 's/http\:\/\/dl-cdn.alpinelinux.org/https\:\/\/alpine.global.ssl.fastly.net/g' /etc/apk/repositories
5+
RUN apk --no-cache add autoconf automake build-base libressl bash curl
6+
7+
# install.sh
8+
ENV ORD_INSTALL_SH="https://raw.githubusercontent.com/ordinals/ord/master/install.sh"
9+
10+
ARG TARGETPLATFORM
11+
ENV TARGET=x86_64-unknown-linux-gnu
12+
13+
RUN wget ${ORD_INSTALL_SH} && chmod +x install.sh \
14+
&& if [ "${TARGETPLATFORM}" = "linux/arm64" ]; then export TARGET=aarch64-apple-darwin; fi \
15+
&& ./install.sh --to /usr/local/bin --target ${TARGET}
16+
17+
# Build stage for compiled artifacts
18+
FROM alpine
19+
20+
# Map host user uid and gid
21+
ARG HOST_UID=100
22+
ARG HOST_GID=101
23+
24+
ENV USER_HOME=/home/ord/
25+
ENV USER_NAME=ord
26+
ENV USER_GROUP=ord
27+
ENV BITCOIN_RPC_LISTEN=127.0.0.1:8332
28+
29+
LABEL maintainer="GeekWho <[email protected]>"
30+
LABEL version="1.0"
31+
LABEL description="An Ordinals ORD docker image"
32+
33+
RUN addgroup ${USER_GROUP} --gid ${HOST_GID} --system
34+
RUN adduser --uid ${HOST_UID} --system ${USER_NAME} --ingroup ${USER_GROUP}
35+
RUN sed -i 's/http\:\/\/dl-cdn.alpinelinux.org/https\:\/\/alpine.global.ssl.fastly.net/g' /etc/apk/repositories
36+
RUN apk --no-cache add \
37+
libevent \
38+
libzmq \
39+
shadow \
40+
sqlite-dev \
41+
su-exec
42+
43+
# fix glibc not work on alpine
44+
ENV GLIBC_REPO=https://github.com/sgerrand/alpine-pkg-glibc
45+
ENV GLIBC_VERSION=2.35-r1
46+
RUN set -ex && \
47+
apk --update add libstdc++ curl ca-certificates && \
48+
for pkg in glibc-${GLIBC_VERSION} glibc-bin-${GLIBC_VERSION}; \
49+
do curl -sSL ${GLIBC_REPO}/releases/download/${GLIBC_VERSION}/${pkg}.apk -o /tmp/${pkg}.apk; done && \
50+
apk add --allow-untrusted /tmp/*.apk && \
51+
rm -v /tmp/*.apk && \
52+
/usr/glibc-compat/sbin/ldconfig /lib /usr/glibc-compat/lib
53+
54+
COPY --from=builder /usr/local/bin/ord /usr/local/bin/
55+
COPY docker-entrypoint.sh /entrypoint.sh
56+
57+
VOLUME ["$USER_HOME"]
58+
59+
EXPOSE 8080
60+
61+
ENTRYPOINT ["/entrypoint.sh"]
62+
63+
CMD ["ord"]
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/sh
2+
set -e
3+
4+
# Check if HOST_UID is set and not 0
5+
if [ -n "${HOST_UID+x}" ] && [ "${HOST_UID}" != "0" ]; then
6+
usermod -u "$HOST_UID" $USER_NAME # Change the user ID to HOST_UID
7+
fi
8+
9+
# Check if HOST_GID is set and not 0
10+
if [ -n "${HOST_GID+x}" ] && [ "${HOST_GID}" != "0" ]; then
11+
if grep -q ":$HOST_GID:" /etc/group; then # if group exists
12+
usermod -a -G $HOST_GID $USER_NAME # Add USER_NAME to Group ID HOST_GID
13+
else
14+
groupmod -g "$HOST_GID" $USER_NAME # Change the group ID to HOST_GID
15+
fi
16+
fi
17+
18+
echo "$0: assuming uid:gid for ${USER_NAME}:${USER_NAME} of $(id -u $USER_NAME):$(id -g $USER_NAME)"
19+
20+
# Get the home directory of $USER_NAME
21+
home_dir=$(getent passwd $USER_NAME | cut -d: -f6)
22+
# Change ownership of the home directory
23+
chown -R $USER_NAME:$HOST_GID ${home_dir}
24+
echo "reset home dir permissions for user ${USER_NAME}:${HOST_GID} done."
25+
echo "start ${USER_NAME} with user ${USER_NAME}..."
26+
exec su-exec $USER_NAME:$HOST_GID "$@" # Execute the command with the specified user
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
FROM ubuntu:23.04 as builder
2+
3+
LABEL maintainer="GeekWho <[email protected]>"
4+
LABEL version="1.0"
5+
LABEL description="A bitcoin-core docker image"
6+
7+
RUN apt-get update -y \
8+
&& apt-get install -y ca-certificates wget curl --no-install-recommends \
9+
&& apt-get clean \
10+
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
11+
12+
# install.sh
13+
ARG ORD_INSTALL_SH="https://raw.githubusercontent.com/ordinals/ord/master/install.sh"
14+
# default ENV
15+
ARG TARGETPLATFORM
16+
ENV TARGET=x86_64-unknown-linux-gnu
17+
18+
RUN wget ${ORD_INSTALL_SH} && chmod +x install.sh \
19+
&& if [ "${TARGETPLATFORM}" = "linux/arm64" ]; then export TARGET=aarch64-apple-darwin; fi \
20+
&& ./install.sh --to /usr/local/bin --target ${TARGET}
21+
22+
# Second stage
23+
FROM ubuntu:23.04
24+
25+
# Map host user uid and gid
26+
ARG HOST_UID=100
27+
ARG HOST_GID=101
28+
29+
ENV USER_HOME=/home/ord/
30+
ENV USER_NAME=ord
31+
ENV USER_GROUP=ord
32+
ENV BITCOIN_RPC_LISTEN=127.0.0.1:8332
33+
34+
RUN groupadd --gid ${HOST_GID} ${USER_GROUP} \
35+
&& useradd --create-home --no-log-init -u ${HOST_UID} -g ${HOST_GID} ${USER_NAME} \
36+
&& apt-get update -y \
37+
&& apt-get install -y gosu curl --no-install-recommends \
38+
&& apt-get clean \
39+
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
40+
41+
COPY --from=builder /usr/local/bin/ord /usr/local/bin/
42+
43+
COPY docker-entrypoint.sh /entrypoint.sh
44+
45+
VOLUME ["$USER_HOME"]
46+
47+
EXPOSE 8080
48+
49+
ENTRYPOINT ["/entrypoint.sh"]
50+
51+
CMD ["ord"]
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/sh
2+
set -e
3+
4+
# Check if HOST_UID is set and not 0
5+
if [ -n "${HOST_UID+x}" ] && [ "${HOST_UID}" != "0" ]; then
6+
usermod -u "$HOST_UID" $USER_NAME # Change the user ID to HOST_UID
7+
fi
8+
9+
# Check if HOST_GID is set and not 0
10+
if [ -n "${HOST_GID+x}" ] && [ "${HOST_GID}" != "0" ]; then
11+
if grep -q ":$HOST_GID:" /etc/group; then # if group exists
12+
usermod -a -G $HOST_GID $USER_NAME # Add USER_NAME to Group ID HOST_GID
13+
else
14+
groupmod -g "$HOST_GID" $USER_NAME # Change the group ID to HOST_GID
15+
fi
16+
fi
17+
18+
echo "$0: assuming uid:gid for ${USER_NAME}:${USER_NAME} of $(id -u $USER_NAME):$(id -g $USER_NAME)"
19+
20+
# Get the home directory of $USER_NAME
21+
home_dir=$(getent passwd $USER_NAME | cut -d: -f6)
22+
# Change ownership of the home directory
23+
chown -R $USER_NAME:$HOST_GID ${home_dir}
24+
echo "reset home dir permissions for user ${USER_NAME}:${HOST_GID} done."
25+
echo "start ${USER_NAME} with user ${USER_NAME}..."
26+
exec gosu $USER_NAME:$HOST_GID "$@" # Execute the command with the specified user

0 commit comments

Comments
 (0)