Skip to content

Commit

Permalink
Merge pull request #74 from zimbora/docker-fork-build2
Browse files Browse the repository at this point in the history
Docker fork build
  • Loading branch information
pedro-at-decenomy authored Oct 3, 2024
2 parents a32ac9d + f3daf94 commit ee458b5
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 37 deletions.
24 changes: 20 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,15 @@ jobs:
run: |
# Extract the name of the repository and use it as the ticker value
REPO_NAME="${GITHUB_REPOSITORY##*/}"
# Extract the name of the repository owner and use it as the github user
ACCOUNT_NAME="${GITHUB_REPOSITORY%/*}"
# Get the short name of the ref (strip 'refs/heads/', 'refs/tags/', etc.)
SHORT_REF=${GITHUB_REF##*/}
# Get the short commit hash
SHORT_COMMIT_HASH=$(git rev-parse --short HEAD)
# Set environment variables
echo "REPO_NAME=${REPO_NAME}" >> $GITHUB_ENV
echo "ACCOUNT_NAME=${ACCOUNT_NAME}" >> $GITHUB_ENV
echo "SHORT_REF=${SHORT_REF}" >> $GITHUB_ENV
echo "IMAGE_NAME=linux-x64-build-img-${SHORT_COMMIT_HASH}" >> $GITHUB_ENV
echo "CONTAINER_NAME=linux-x64-build-ctn-${SHORT_COMMIT_HASH}" >> $GITHUB_ENV
Expand All @@ -40,6 +43,7 @@ jobs:
--build-arg NAME=__Decenomy__ \
--build-arg BASE_NAME=__decenomy__ \
--build-arg TARGET=$SHORT_REF \
--build-arg GITHUB_USER=$ACCOUNT_NAME \
-t ${IMAGE_NAME} \
-f contrib/docker/Dockerfile.dsw-linux-x64-wallet .
Expand All @@ -50,7 +54,7 @@ jobs:
mkdir release_files
# Copy files from the Docker container to the local filesystem
docker cp ${CONTAINER_NAME}:/$REPO_NAME/deploy/linux-x64 release_files/
docker cp ${CONTAINER_NAME}:/$ACCOUNT_NAME/$REPO_NAME/deploy/linux-x64 release_files/
- name: Archive and Upload Extracted Files
uses: actions/upload-artifact@v4
Expand All @@ -76,12 +80,15 @@ jobs:
run: |
# Extract the name of the repository and use it as the ticker value
REPO_NAME="${GITHUB_REPOSITORY##*/}"
# Extract the name of the repository owner and use it as the github user
ACCOUNT_NAME="${GITHUB_REPOSITORY%/*}"
# Get the short name of the ref (strip 'refs/heads/', 'refs/tags/', etc.)
SHORT_REF=${GITHUB_REF##*/}
# Get the short commit hash
SHORT_COMMIT_HASH=$(git rev-parse --short HEAD)
# Set environment variables
echo "REPO_NAME=${REPO_NAME}" >> $GITHUB_ENV
echo "ACCOUNT_NAME=${ACCOUNT_NAME}" >> $GITHUB_ENV
echo "SHORT_REF=${SHORT_REF}" >> $GITHUB_ENV
echo "IMAGE_NAME=linux-arm64-build-img-${SHORT_COMMIT_HASH}" >> $GITHUB_ENV
echo "CONTAINER_NAME=linux-arm64-build-ctn-${SHORT_COMMIT_HASH}" >> $GITHUB_ENV
Expand All @@ -99,6 +106,7 @@ jobs:
--build-arg NAME=__Decenomy__ \
--build-arg BASE_NAME=__decenomy__ \
--build-arg TARGET=$SHORT_REF \
--build-arg GITHUB_USER=$ACCOUNT_NAME \
-t ${IMAGE_NAME} \
-f contrib/docker/Dockerfile.dsw-linux-arm64-wallet .
Expand All @@ -109,7 +117,7 @@ jobs:
mkdir release_files
# Copy files from the Docker container to the local filesystem
docker cp ${CONTAINER_NAME}:/$REPO_NAME/deploy/linux-arm64 release_files/
docker cp ${CONTAINER_NAME}:/$ACCOUNT_NAME/$REPO_NAME/deploy/linux-arm64 release_files/
- name: Archive and Upload Extracted Files
uses: actions/upload-artifact@v4
Expand All @@ -135,12 +143,15 @@ jobs:
run: |
# Extract the name of the repository and use it as the ticker value
REPO_NAME="${GITHUB_REPOSITORY##*/}"
# Extract the name of the repository owner and use it as the github user
ACCOUNT_NAME="${GITHUB_REPOSITORY%/*}"
# Get the short name of the ref (strip 'refs/heads/', 'refs/tags/', etc.)
SHORT_REF=${GITHUB_REF##*/}
# Get the short commit hash
SHORT_COMMIT_HASH=$(git rev-parse --short HEAD)
# Set environment variables
echo "REPO_NAME=${REPO_NAME}" >> $GITHUB_ENV
echo "ACCOUNT_NAME=${ACCOUNT_NAME}" >> $GITHUB_ENV
echo "SHORT_REF=${SHORT_REF}" >> $GITHUB_ENV
echo "IMAGE_NAME=windows-x64-build-img-${SHORT_COMMIT_HASH}" >> $GITHUB_ENV
echo "CONTAINER_NAME=windows-x64-build-ctn-${SHORT_COMMIT_HASH}" >> $GITHUB_ENV
Expand All @@ -158,6 +169,7 @@ jobs:
--build-arg NAME=__Decenomy__ \
--build-arg BASE_NAME=__decenomy__ \
--build-arg TARGET=$SHORT_REF \
--build-arg GITHUB_USER=$ACCOUNT_NAME \
-t ${IMAGE_NAME} \
-f contrib/docker/Dockerfile.dsw-windows-x64-wallet .
Expand All @@ -168,7 +180,7 @@ jobs:
mkdir release_files
# Copy files from the Docker container to the local filesystem
docker cp ${CONTAINER_NAME}:/$REPO_NAME/deploy/windows-x64 release_files/
docker cp ${CONTAINER_NAME}:/$ACCOUNT_NAME/$REPO_NAME/deploy/windows-x64 release_files/
- name: Archive and Upload Extracted Files
uses: actions/upload-artifact@v4
Expand All @@ -194,12 +206,15 @@ jobs:
run: |
# Extract the name of the repository and use it as the ticker value
REPO_NAME="${GITHUB_REPOSITORY##*/}"
# Extract the name of the repository owner and use it as the github user
ACCOUNT_NAME="${GITHUB_REPOSITORY%/*}"
# Get the short name of the ref (strip 'refs/heads/', 'refs/tags/', etc.)
SHORT_REF=${GITHUB_REF##*/}
# Get the short commit hash
SHORT_COMMIT_HASH=$(git rev-parse --short HEAD)
# Set environment variables
echo "REPO_NAME=${REPO_NAME}" >> $GITHUB_ENV
echo "ACCOUNT_NAME=${ACCOUNT_NAME}" >> $GITHUB_ENV
echo "SHORT_REF=${SHORT_REF}" >> $GITHUB_ENV
echo "IMAGE_NAME=macos-x64-build-img-${SHORT_COMMIT_HASH}" >> $GITHUB_ENV
echo "CONTAINER_NAME=macos-x64-build-ctn-${SHORT_COMMIT_HASH}" >> $GITHUB_ENV
Expand All @@ -217,6 +232,7 @@ jobs:
--build-arg NAME=__Decenomy__ \
--build-arg BASE_NAME=__decenomy__ \
--build-arg TARGET=$SHORT_REF \
--build-arg GITHUB_USER=$ACCOUNT_NAME \
-t ${IMAGE_NAME} \
-f contrib/docker/Dockerfile.dsw-macos-x64-wallet .
Expand All @@ -227,7 +243,7 @@ jobs:
mkdir release_files
# Copy files from the Docker container to the local filesystem
docker cp ${CONTAINER_NAME}:/$REPO_NAME/deploy/macos-x64 release_files/
docker cp ${CONTAINER_NAME}:/$ACCOUNT_NAME/$REPO_NAME/deploy/macos-x64 release_files/
- name: Archive and Upload Extracted Files
uses: actions/upload-artifact@v4
Expand Down
24 changes: 18 additions & 6 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,26 @@ CPU_CORES=${CPU_CORES:-""}
# windows-x64
ARCHITECTURE=${ARCHITECTURE:-""}

# Get the origin URL
ORIGIN_URL=$(git config --get remote.origin.url)

# Extract the github username and repository name
if [[ $ORIGIN_URL =~ ^https://github.com/(.+)/(.+)\.git$ ]]; then
GITHUB_USER="${BASH_REMATCH[1]}"
GITHUB_REPO="${BASH_REMATCH[2]}"
elif [[ $ORIGIN_URL =~ ^[email protected]:(.+)/(.+)\.git$ ]]; then
GITHUB_USER="${BASH_REMATCH[1]}"
GITHUB_REPO="${BASH_REMATCH[2]}"
else
echo "Unable to parse origin URL: $ORIGIN_URL"
exit 1
fi

# Sets variables needed for the build
TICKER=${TICKER:-"__DSW__"}
TICKER=${TICKER:-"${GITHUB_REPO}"}
UI_NAME=${UI_NAME:-"__Decenomy__"}
BASE_NAME=${BASE_NAME:-"__decenomy__"}

# Sets the github environment variables
GITHUB_USER="decenomy"
GITHUB_REPO="__DSW__"

# Sets the build environment variable
# 0: The build will use the builder image available on docker hub
# 1: The build will use a locally build image for the builder image
Expand Down Expand Up @@ -227,6 +238,7 @@ docker buildx build \
--build-arg NAME=$UI_NAME \
--build-arg BASE_NAME=$BASE_NAME \
--build-arg TARGET=$TARGET \
--build-arg GITHUB_USER=$GITHUB_USER \
-f $WALLET_DOCKER_FILE.tmp \
-t $image_tag \
.
Expand All @@ -246,7 +258,7 @@ trace "Container ID: $container_id"
# Copy files from the container to the current directory
mkdir -p deploy
rm -rf deploy/$ARCHITECTURE
docker cp "$container_id":/${TICKER}/deploy/. ./deploy/
docker cp "$container_id":/${GITHUB_USER}/${TICKER}/deploy/. ./deploy/

# Main verification process
if [ "$VERIFY" -ge 1 ]; then
Expand Down
15 changes: 10 additions & 5 deletions contrib/docker/Dockerfile.dsw-linux-arm64-wallet
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,21 @@ ARG TICKER=__DSW__
ARG NAME=__Decenomy__
ARG BASE_NAME=__decenomy__
ARG TARGET=master
ARG GITHUB_USER=decenomy

RUN sleep 30

RUN mkdir -p ${GITHUB_USER}
# Switch to the github user directory
WORKDIR /$GITHUB_USER

# Clone the repository
RUN if [ ! -d $TICKER ]; then \
git clone https://github.com/decenomy/$TICKER; \
git clone https://github.com/${GITHUB_USER}/${TICKER}.git; \
fi

# Switch to the repository directory
WORKDIR /$TICKER
WORKDIR /${GITHUB_USER}/${TICKER}

# Check out the $TARGET
RUN git stash --include-untracked && \
Expand Down Expand Up @@ -63,9 +68,9 @@ RUN PATH=${WRAP_DIR}:${PATH} aarch64-linux-gnu-objcopy --strip-all src/$(echo $B
RUN PATH=${WRAP_DIR}:${PATH} aarch64-linux-gnu-objcopy --strip-all src/$(echo $BASE_NAME)-cli
RUN PATH=${WRAP_DIR}:${PATH} aarch64-linux-gnu-objcopy --strip-all src/$(echo $BASE_NAME)-tx
RUN PATH=${WRAP_DIR}:${PATH} aarch64-linux-gnu-objcopy --strip-all src/qt/$(echo $BASE_NAME)-qt
RUN cp src/$(echo $BASE_NAME)d src/$(echo $BASE_NAME)-cli src/$(echo $BASE_NAME)-tx src/qt/$(echo $BASE_NAME)-qt /$TICKER/deploy/linux-arm64
RUN find /$TICKER/deploy/linux-arm64 -type f -exec touch -t $(cat /git_timestamp_touch) {} +
WORKDIR /$TICKER/deploy/linux-arm64
RUN cp src/$(echo $BASE_NAME)d src/$(echo $BASE_NAME)-cli src/$(echo $BASE_NAME)-tx src/qt/$(echo $BASE_NAME)-qt /${GITHUB_USER}/${TICKER}/deploy/linux-arm64
RUN find /${GITHUB_USER}/${TICKER}/deploy/linux-arm64 -type f -exec touch -t $(cat /git_timestamp_touch) {} +
WORKDIR /${GITHUB_USER}/${TICKER}/deploy/linux-arm64
RUN PATH=${WRAP_DIR}:${PATH} zip -X $TICKER-$(cat /wallet_version)-Linux-arm64.zip $(echo $BASE_NAME)d $(echo $BASE_NAME)-cli $(echo $BASE_NAME)-tx $(echo $BASE_NAME)-qt
RUN echo "$(git rev-parse HEAD) commit" >> SHA256SUMS-Linux-arm64.ASC
RUN sha256sum $(echo $BASE_NAME)d >> SHA256SUMS-Linux-arm64.ASC
Expand Down
15 changes: 10 additions & 5 deletions contrib/docker/Dockerfile.dsw-linux-x64-wallet
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,21 @@ ARG TICKER=__DSW__
ARG NAME=__Decenomy__
ARG BASE_NAME=__decenomy__
ARG TARGET=master
ARG GITHUB_USER=decenomy

RUN sleep 30

RUN mkdir -p ${GITHUB_USER}
# Switch to the github user directory
WORKDIR /$GITHUB_USER

# Clone the repository
RUN if [ ! -d $TICKER ]; then \
git clone https://github.com/decenomy/$TICKER; \
git clone https://github.com/${GITHUB_USER}/${TICKER}.git; \
fi

# Switch to the repository directory
WORKDIR /$TICKER
WORKDIR /${GITHUB_USER}/${TICKER}

# Check out the $TARGET
RUN git stash --include-untracked && \
Expand Down Expand Up @@ -61,9 +66,9 @@ RUN grep "define(_CLIENT_VERSION_BUILD" configure.ac | awk -F"[ ,)]" '{print $3}
# Create deploy files
RUN mkdir -p deploy/linux-x64
RUN PATH=${WRAP_DIR}:${PATH} strip -s src/$(echo $BASE_NAME)d src/$(echo $BASE_NAME)-cli src/$(echo $BASE_NAME)-tx src/qt/$(echo $BASE_NAME)-qt
RUN cp src/$(echo $BASE_NAME)d src/$(echo $BASE_NAME)-cli src/$(echo $BASE_NAME)-tx src/qt/$(echo $BASE_NAME)-qt /$TICKER/deploy/linux-x64
RUN find /$TICKER/deploy/linux-x64 -type f -exec touch -t $(cat /git_timestamp_touch) {} +
WORKDIR /$TICKER/deploy/linux-x64
RUN cp src/$(echo $BASE_NAME)d src/$(echo $BASE_NAME)-cli src/$(echo $BASE_NAME)-tx src/qt/$(echo $BASE_NAME)-qt /${GITHUB_USER}/${TICKER}/deploy/linux-x64
RUN find /${GITHUB_USER}/${TICKER}/deploy/linux-x64 -type f -exec touch -t $(cat /git_timestamp_touch) {} +
WORKDIR /${GITHUB_USER}/${TICKER}/deploy/linux-x64
RUN PATH=${WRAP_DIR}:${PATH} zip -X $TICKER-$(cat /wallet_version)-Linux-x64.zip $(echo $BASE_NAME)d $(echo $BASE_NAME)-cli $(echo $BASE_NAME)-tx $(echo $BASE_NAME)-qt
RUN echo "$(git rev-parse HEAD) commit" >> SHA256SUMS-Linux-x64.ASC
RUN sha256sum $(echo $BASE_NAME)d >> SHA256SUMS-Linux-x64.ASC
Expand Down
15 changes: 10 additions & 5 deletions contrib/docker/Dockerfile.dsw-macos-x64-wallet
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,21 @@ ARG TICKER=__DSW__
ARG NAME=__Decenomy__
ARG BASE_NAME=__decenomy__
ARG TARGET=master
ARG GITHUB_USER=decenomy

RUN sleep 30

RUN mkdir -p ${GITHUB_USER}
# Switch to the github user directory
WORKDIR /$GITHUB_USER

# Clone the repository
RUN if [ ! -d $TICKER ]; then \
git clone https://github.com/decenomy/$TICKER; \
git clone https://github.com/${GITHUB_USER}/${TICKER}.git; \
fi

# Switch to the repository directory
WORKDIR /$TICKER
WORKDIR /${GITHUB_USER}/${TICKER}

# Check out the $TARGET
RUN git stash --include-untracked && \
Expand Down Expand Up @@ -65,9 +70,9 @@ RUN PATH=${WRAP_DIR}:/DSW/depends/x86_64-apple-darwin14/native/bin/:${PATH} \

# Create deploy files
RUN mkdir -p deploy/macos-x64
RUN cp src/$(echo $BASE_NAME)d src/$(echo $BASE_NAME)-cli src/$(echo $BASE_NAME)-tx src/qt/$(echo $BASE_NAME)-qt $(echo $NAME)-Core.dmg /$TICKER/deploy/macos-x64
RUN find /$TICKER/deploy/macos-x64 -type f -exec touch -t $(cat /git_timestamp_touch) {} +
WORKDIR /$TICKER/deploy/macos-x64
RUN cp src/$(echo $BASE_NAME)d src/$(echo $BASE_NAME)-cli src/$(echo $BASE_NAME)-tx src/qt/$(echo $BASE_NAME)-qt $(echo $NAME)-Core.dmg /${GITHUB_USER}/${TICKER}/deploy/macos-x64
RUN find /${GITHUB_USER}/${TICKER}/deploy/macos-x64 -type f -exec touch -t $(cat /git_timestamp_touch) {} +
WORKDIR /${GITHUB_USER}/${TICKER}/deploy/macos-x64
RUN PATH=${WRAP_DIR}:${PATH} zip -X $TICKER-$(cat /wallet_version)-MacOS-x64.zip $(echo $BASE_NAME)d $(echo $BASE_NAME)-cli $(echo $BASE_NAME)-tx $(echo $BASE_NAME)-qt $(echo $NAME)-Core.dmg
RUN echo "$(git rev-parse HEAD) commit" >> SHA256SUMS-MacOS-x64.ASC
RUN sha256sum $(echo $BASE_NAME)d >> SHA256SUMS-MacOS-x64.ASC
Expand Down
29 changes: 17 additions & 12 deletions contrib/docker/Dockerfile.dsw-windows-x64-wallet
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,21 @@ ARG TICKER=__DSW__
ARG NAME=__Decenomy__
ARG BASE_NAME=__decenomy__
ARG TARGET=master
ARG GITHUB_USER=decenomy

RUN sleep 30

RUN mkdir -p ${GITHUB_USER}
# Switch to the github user directory
WORKDIR /$GITHUB_USER

# Clone the repository
RUN if [ ! -d $TICKER ]; then \
git clone https://github.com/decenomy/$TICKER; \
git clone https://github.com/${GITHUB_USER}/${TICKER}.git; \
fi

# Switch to the repository directory
WORKDIR /$TICKER
WORKDIR /${GITHUB_USER}/${TICKER}

# Check out the $TARGET
RUN git stash --include-untracked && \
Expand Down Expand Up @@ -69,10 +74,10 @@ RUN cp \
src/$(echo $BASE_NAME)-cli.exe \
src/$(echo $BASE_NAME)-tx.exe \
src/qt/$(echo $BASE_NAME)-qt.exe \
/$TICKER/deploy/windows-x64
RUN find /$TICKER/deploy/windows-x64 -type f -exec touch -t $(cat /git_timestamp_touch) {} +
/${GITHUB_USER}/${TICKER}/deploy/windows-x64
RUN find /${GITHUB_USER}/${TICKER}/deploy/windows-x64 -type f -exec touch -t $(cat /git_timestamp_touch) {} +

WORKDIR /$TICKER/deploy/windows-x64
WORKDIR /${GITHUB_USER}/${TICKER}/deploy/windows-x64
RUN PATH=${WRAP_DIR}:${PATH} zip -X $TICKER-$(cat /wallet_version)-Windows-x64.zip \
$(echo $BASE_NAME)d.exe \
$(echo $BASE_NAME)-cli.exe \
Expand All @@ -87,17 +92,17 @@ RUN sha256sum $(echo $BASE_NAME)-qt.exe >> SHA256SUMS-Windows-x64.ASC
RUN sha256sum $TICKER-$(cat /wallet_version)-Windows-x64.zip >> SHA256SUMS-Windows-x64.ASC

# Set the Inno Setup compiler
RUN mkdir -p /$TICKER/contrib/innosetup/package
RUN cp $(echo $BASE_NAME)* /$TICKER/contrib/innosetup/package/
RUN find /$TICKER/contrib/innosetup/ -type f -exec touch -t $(cat /git_timestamp_touch) {} +
RUN find /$TICKER/contrib/innosetup/package/ -type f -exec touch -t $(cat /git_timestamp_touch) {} +
RUN mkdir -p /${GITHUB_USER}/${TICKER}/contrib/innosetup/package
RUN cp $(echo $BASE_NAME)* /${GITHUB_USER}/${TICKER}/contrib/innosetup/package/
RUN find /${GITHUB_USER}/${TICKER}/contrib/innosetup/ -type f -exec touch -t $(cat /git_timestamp_touch) {} +
RUN find /${GITHUB_USER}/${TICKER}/contrib/innosetup/package/ -type f -exec touch -t $(cat /git_timestamp_touch) {} +

WORKDIR /$TICKER/contrib/innosetup
WORKDIR /${GITHUB_USER}/${TICKER}/contrib/innosetup

RUN PATH=${WRAP_DIR}:${PATH} wine ~/.wine/drive_c/Program\ Files\ \(x86\)/Inno\ Setup\ 6/ISCC.exe setup.iss
RUN mv output/$(echo $NAME)Setup.exe /$TICKER/deploy/windows-x64/$(echo $NAME)-$(cat /wallet_version)-Setup.exe
RUN mv output/$(echo $NAME)Setup.exe /${GITHUB_USER}/${TICKER}/deploy/windows-x64/$(echo $NAME)-$(cat /wallet_version)-Setup.exe

WORKDIR /$TICKER/deploy/windows-x64
WORKDIR /${GITHUB_USER}/${TICKER}/deploy/windows-x64
RUN touch -t $(cat /git_timestamp_touch) $(echo $NAME)-$(cat /wallet_version)-Setup.exe
RUN PATH=${WRAP_DIR}:${PATH} zip -X $TICKER-$(cat /wallet_version)-WindowsSetup-x64.zip \
$(echo $NAME)-$(cat /wallet_version)-Setup.exe
Expand Down

0 comments on commit ee458b5

Please sign in to comment.