Skip to content

Commit f2287d5

Browse files
authored
Merge pull request #8 from seia-soto/rework-git-patch
2 parents 24f3e36 + ceb61b7 commit f2287d5

11 files changed

+201
-136
lines changed

.github/workflows/build.yml

Lines changed: 7 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -10,34 +10,27 @@ jobs:
1010
version:
1111
runs-on: ubuntu-latest
1212
outputs:
13-
local_release: ${{steps.local.outputs.release}}
1413
local_tag: ${{steps.local.outputs.tag}}
15-
remote_release: ${{steps.remote.outputs.release}}
1614
remote_tag: ${{steps.remote.outputs.tag}}
17-
is_release_build_required: ${{steps.test.outputs.release}}
1815
is_latest_build_required: ${{steps.test.outputs.latest}}
1916
steps:
2017
- name: Get remote version
2118
id: remote
2219
run: |
23-
echo ::set-output name=tag::"$(curl -sL https://api.github.com/repos/Jigsaw-Code/outline-server/tags | jq -r '.[0].name')"
24-
echo ::set-output name=release::"$(curl -sL https://api.github.com/repos/Jigsaw-Code/outline-server/releases | jq -r '[.[] | select(.prerelease == false)][0].tag_name')"
20+
git clone https://github.com/Jigsaw-Code/outline-server.git outline-server
21+
cd outline-server
22+
echo "::set-output name=tag::$(git describe --tags --abbrev=0)"
2523
- name: Get local release
2624
id: local
2725
run: |
28-
echo ::set-output name=tag::"$(curl -sL "https://api.github.com/repos/${{github.repository}}/releases" | jq -r '[.[] | select(.tag_name | startswith("latest-"))][0].name')"
29-
echo ::set-output name=release::"$(curl -sL "https://api.github.com/repos/${{github.repository}}/releases" | jq -r '[.[] | select(.tag_name | startswith("release-"))][0].tag_name')"
26+
echo ::set-output name=tag::"$(curl -sL "https://api.github.com/repos/${{github.repository}}/releases" | jq -r '[.[] | select(.name | startswith("latest-"))][0].name')"
3027
- name: Test
3128
id: test
3229
run: |
3330
if [[ "latest-${{steps.remote.outputs.tag}}" != "${{steps.local.outputs.tag}}" ]];
3431
then
3532
echo "::set-output name=latest::true"
3633
fi
37-
if [[ "release-${{steps.remote.outputs.release}}" != "${{steps.local.outputs.release}}" ]];
38-
then
39-
echo "::set-output name=release::true"
40-
fi
4134
build_master:
4235
needs: [version]
4336
runs-on: ubuntu-20.04
@@ -62,7 +55,7 @@ jobs:
6255
password: ${{secrets.GITHUB_TOKEN}}
6356
- name: Build and push
6457
run: |
65-
bash ./build.sh "${{env.ARCH}}" "${{env.PACKAGE_NAME}}:master" "master" "false"
58+
bash ./build.sh "${{env.ARCH}}" "${{env.PACKAGE_NAME}}:master" "master"
6659
build_latest:
6760
needs: [version]
6861
runs-on: ubuntu-20.04
@@ -72,7 +65,7 @@ jobs:
7265
uses: actions/checkout@v2
7366
- uses: actions/setup-node@v3
7467
with:
75-
node-version: 12
68+
node-version: 16
7669
- name: Setup QEMU
7770
uses: docker/setup-qemu-action@v1
7871
with:
@@ -88,7 +81,7 @@ jobs:
8881
password: ${{secrets.GITHUB_TOKEN}}
8982
- name: Build and push
9083
run: |
91-
bash ./build.sh "${{env.ARCH}}" "${{env.PACKAGE_NAME}}:latest" "${{needs.version.outputs.remote_tag}}" "true"
84+
bash ./build.sh "${{env.ARCH}}" "${{env.PACKAGE_NAME}}:latest" "${{needs.version.outputs.remote_tag}}"
9285
- name: Conditional release
9386
uses: actions/create-release@v1
9487
env:
@@ -100,42 +93,4 @@ jobs:
10093
This release is for identification use of CI script.
10194
Please, read README to deploy this package.
10295
draft: false
103-
prerelease: true
104-
build_release:
105-
needs: [version]
106-
runs-on: ubuntu-20.04
107-
if: needs.version.outputs.is_release_build_required == 'true'
108-
steps:
109-
- name: Checkout repository
110-
uses: actions/checkout@v2
111-
- uses: actions/setup-node@v3
112-
with:
113-
node-version: 12
114-
- name: Setup QEMU
115-
uses: docker/setup-qemu-action@v1
116-
with:
117-
image: tonistiigi/binfmt:latest
118-
platforms: all
119-
- name: Set up Docker Buildx
120-
uses: docker/setup-buildx-action@v1
121-
- name: Login to GitHub Container Registry
122-
uses: docker/login-action@v1
123-
with:
124-
registry: ghcr.io
125-
username: ${{github.repository_owner}}
126-
password: ${{secrets.GITHUB_TOKEN}}
127-
- name: Build and push
128-
run: |
129-
bash ./build.sh "${{env.ARCH}}" "${{env.PACKAGE_NAME}}:release" "${{needs.version.outputs.remote_release}}" "true"
130-
- name: Conditional release
131-
uses: actions/create-release@v1
132-
env:
133-
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
134-
with:
135-
tag_name: "release-${{needs.version.outputs.remote_release}}"
136-
release_name: "release-${{needs.version.outputs.remote_release}}"
137-
body: |
138-
This release is for identification use of CI script.
139-
Please, read README to deploy this package.
140-
draft: false
14196
prerelease: false

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/workspace

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
MIT License Copyright 2022 HoJeong Go
1+
MIT License Copyright 2022-2023 HoJeong Go
22

33
Permission is hereby granted, free of
44
charge, to any person obtaining a copy of this software and associated

Makefile

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
help:
2+
@echo "use: $(MAKE) [clone-upstream]"
3+
@echo ""
4+
@echo " clone-upstream -> clone upstream(Jigsaw-Code/outline-server) into ./workspace/outline-server"
5+
@echo " apply-patches -> patch diff files into ./workspace/outline-server"
6+
@echo " create-patch -> create patch file from workspace TARGET=target_to_execute_diff"
7+
@echo " clean -> clean workspace directory"
8+
9+
clone-upstream:
10+
mkdir -p ./workspace;
11+
@if [[ ! -d ./workspace/outline-server ]]; then \
12+
git clone https://github.com/Jigsaw-Code/outline-server.git ./workspace/outline-server; \
13+
else \
14+
cd ./workspace/outline-server; \
15+
git pull; \
16+
fi;
17+
18+
apply-patches:
19+
@cd ./workspace/outline-server; \
20+
for FILE in ../../patches/*.patch; do \
21+
[[ -e "$${FILE}" ]] || continue; \
22+
echo "Applying $${FILE}"; \
23+
git apply "$${FILE}"; \
24+
done;
25+
26+
create-patch:
27+
@cd ./workspace/outline-server; \
28+
git diff $(TARGET) > ../../patches/_.patch;
29+
30+
clean:
31+
rm -rf ./workspace/outline-server;

README.md

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@ The multi-arch distribution of [Jigsaw's Outline-Server](https://github.com/Jigs
66
|---------|----------------------------------------------|-----------------|------------------------------------------------------|
77
| master | daily | upstream/master | linux/amd64, linux/arm64, linux/arm/v7, linux/arm/v6 |
88
| latest | checked daily, released as upstream tags | Latest tag | linux/amd64, linux/arm64, linux/arm/v7, linux/arm/v6 |
9-
| release | checked daily, released as upstream releases | Latest release | linux/amd64, linux/arm64, linux/arm/v7, linux/arm/v6 |
9+
| release | checked daily, not more updated (legacy) | v1.9 or lower | linux/amd64, linux/arm64, linux/arm/v7, linux/arm/v6 |
1010

1111
## Usage
1212

1313
To install outline-server on your server using this docker image, paste following code before install:
1414

1515
```bash
16-
# master release, updated daily
16+
# master release, updated daily (might fail sometime)
1717
export SB_IMAGE="ghcr.io/seia-soto/shadowbox:master"
1818

19-
# stable release, updated infrequently
19+
# stable release, NOT MORE UPDATED (It is for outline-server v1.9 or lower, use `latest` instead)
2020
export SB_IMAGE="ghcr.io/seia-soto/shadowbox:release"
2121

2222
# latest release, updated irregularly
@@ -26,9 +26,21 @@ export SB_IMAGE="ghcr.io/seia-soto/shadowbox:latest"
2626
curl -sL "https://raw.githubusercontent.com/Jigsaw-Code/outline-server/master/src/server_manager/install_scripts/install_server.sh" | sed '/local MACHINE_TYPE/,/fi/{d}' | bash
2727
```
2828

29+
## Development
30+
31+
### Patching
32+
33+
There're Makefile in this repository and contains some useful commands for development, but you can continue only with `git diff` command.
34+
35+
Use `make help` to print help script.
36+
37+
Starting with `make clone-upstream apply-patches` would be help.
38+
2939
### Local build
3040

31-
To build local image, you can use following command with prepared environment:
41+
> The build script uses Docker Buildx and you cannot publish the output image directly to the Docker daemon.
42+
43+
To build image locally, you can use following command with prepared environment:
3244

3345
- For **single-arch** build, you just need to install:
3446
- `jq`
@@ -52,16 +64,21 @@ cd outline-server-multiarch
5264
5365
Usage:
5466
55-
./build.sh $arch $tag $checkpoint $use_legacy_install
67+
./build.sh $arch $tag $checkpoint
68+
69+
-- Arguments:
5670
5771
$arch {string} The arch to build, using docker platform style
5872
$tag {string} The docker tag to use while building the image
5973
$checkpoint {string} The git branch or tag to checkout on Jigsaw-Code/Outline-Server
60-
$use_legacy_install {boolean} Set as true to build recent versions of outline-server using Node.JS v16 (likely on master branch)
74+
75+
-- Environments:
76+
77+
$AB_LEAVE_BASE_DIRECTORY {any} If it is not empty string, script will not clean working directory
6178
6279
About:
6380
64-
This script builds Outline-Server docker image
81+
This script builds Outline-Server docker buildx image
6582
with specific arch by downloading compatible third_party
6683
automatically.
6784
'
@@ -73,7 +90,7 @@ PLATFORM="linux/amd64" # use one of linux/amd64,linux/arm64,linux/arm/v7,linux/a
7390
CHECKPOINT="latest" # use latest for latest tag or `master`
7491

7592
# build latest, use false for use_legacy_install if you're building master branch
76-
bash ./build.sh "${PLATFORM}" "${SB_IMAGE}" "${CHECKPOINT}" "true"
93+
bash ./build.sh "${PLATFORM}" "${SB_IMAGE}" "${CHECKPOINT}"
7794

7895
# run install script
7996
curl -sL "https://raw.githubusercontent.com/Jigsaw-Code/outline-server/master/src/server_manager/install_scripts/install_server.sh" | sed '/local MACHINE_TYPE/,/fi/{d}' | bash
@@ -101,7 +118,7 @@ Also, the build script which named `/build.sh` will clone the Outline-Server rep
101118
Other files which created by HoJeong Go (a.k.a Seia-Soto) has been licensed with [MIT License](./LICENSE).
102119

103120
```
104-
MIT License Copyright 2022 HoJeong Go
121+
MIT License Copyright 2022-2023 HoJeong Go
105122
106123
Permission is hereby granted, free of
107124
charge, to any person obtaining a copy of this software and associated

build.sh

Lines changed: 25 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,21 @@ set -x
66
77
Usage:
88
9-
./build.sh $arch $tag $checkpoint $use_legacy_install
9+
./build.sh $arch $tag $checkpoint
10+
11+
-- Arguments:
1012
1113
$arch {string} The arch to build, using docker platform style
1214
$tag {string} The docker tag to use while building the image
1315
$checkpoint {string} The git branch or tag to checkout on Jigsaw-Code/Outline-Server
14-
$use_legacy_install {boolean} Set as true to build recent versions of outline-server using Node.JS v16 (likely on master branch)
16+
17+
-- Environments:
18+
19+
$AB_LEAVE_BASE_DIRECTORY {any} If it is not empty string, script will not clean working directory
1520
1621
About:
1722
18-
This script builds Outline-Server docker image
23+
This script builds Outline-Server docker buildx image
1924
with specific arch by downloading compatible third_party
2025
automatically.
2126
'
@@ -34,7 +39,6 @@ TMP=$(mktemp -d)
3439
ARCH=${1}
3540
TAG=${2}
3641
CHECKPOINT=${3}
37-
USE_LEGACY_INSTALL=${4}
3842

3943
export DOCKER_PLATFORMS="${ARCH}"
4044

@@ -68,16 +72,14 @@ unpack_archive_from_url() {
6872
remap_arch() {
6973
local ARCH="${1}" AMD64="${2:-amd64}" ARM64="${3:-arm64}" ARMv7="${4:-armv7}" ARMv6="${5:-armv6}"
7074

71-
[[ "${ARCH}" == *"amd64"* ]] && ARCH="${AMD64}"
72-
[[ "${ARCH}" == *"arm64"* ]] && ARCH="${ARM64}"
73-
[[ "${ARCH}" == *"v7"* ]] && ARCH="${ARMv7}"
74-
[[ "${ARCH}" == *"v6"* ]] && ARCH="${ARMv6}"
75-
76-
echo "${ARCH}"
75+
[[ "${ARCH}" == *"amd64"* ]] && echo "${AMD64}"
76+
[[ "${ARCH}" == *"arm64"* ]] && echo "${ARM64}"
77+
[[ "${ARCH}" == *"v7"* ]] && echo "${ARMv7}"
78+
[[ "${ARCH}" == *"v6"* ]] && echo "${ARMv6}"
7779
}
7880

7981
# Clone outline-server
80-
git clone "https://github.com/${REPO_BASE}.git" "${NS_BASE}"
82+
[[ ! -d "./outline-server" ]] && git clone "https://github.com/${REPO_BASE}.git" "${NS_BASE}"
8183

8284
# Go to repo and checkout to latest release
8385
cd "${NS_BASE}"
@@ -98,44 +100,33 @@ do
98100

99101
unpack_archive_from_url "${NS_SSS}.${ARCH_SSS}" "${RES_SSS}" "0"
100102

101-
mkdir -p "third_parties/${C_ARCH}/outline-ss-server/linux"
102-
mv "${TMP}/${NS_SSS}.${ARCH_SSS}/outline-ss-server" "third_parties/${C_ARCH}/outline-ss-server/linux"
103+
mkdir -p "third_parties/${C_ARCH}/outline-ss-server"
104+
mv "${TMP}/${NS_SSS}.${ARCH_SSS}/outline-ss-server" "third_parties/${C_ARCH}/outline-ss-server/"
103105

104106
# Download prometheus
105107
ARCH_PROM="$(remap_arch "${C_ARCH}" amd64 arm64 armv7 armv6)"
106108
RES_PROM="$(gh_release_asset_url_by_arch "${REPO_PROM}" "linux-${ARCH_PROM}")"
107109

108110
unpack_archive_from_url "${NS_PROM}.${ARCH_PROM}" "${RES_PROM}" "1"
109111

110-
mkdir -p "third_parties/${C_ARCH}/prometheus/linux"
111-
mv "${TMP}/${NS_PROM}.${ARCH_PROM}/prometheus" "third_parties/${C_ARCH}/prometheus/linux"
112+
mkdir -p "third_parties/${C_ARCH}/prometheus"
113+
mv "${TMP}/${NS_PROM}.${ARCH_PROM}/prometheus" "third_parties/${C_ARCH}/prometheus/"
112114
done
113115

114-
# Modify build environment
115-
sed -i -e \
116-
'/COPY third_party/s/^COPY third_party third_party/ARG TARGETPLATFORM\nCOPY third_parties\/\$\{TARGETPLATFORM\} third_party/' \
117-
"src/shadowbox/docker/Dockerfile"
116+
# Apply patches
117+
for FILE in ../patches/*.patch; do
118+
[[ -e "${FILE}" ]] || continue;
119+
git apply "${FILE}";
120+
done;
118121

119122
# Build docker-image
120123
export SB_IMAGE="${TAG}"
121-
export DOCKER_CONTENT_TRUST="0"
122-
123-
if [[ "${USE_LEGACY_INSTALL}" == "true" ]]; then
124-
export NODE_IMAGE="node:12-alpine"
124+
export NODE_IMAGE="node:16-alpine"
125125

126-
\cp -f "../extra/scripts/build.action.sh" "src/shadowbox/docker/build_action.sh"
127-
128-
npm run do shadowbox/docker/build
129-
else
130-
export NODE_IMAGE="node:16-alpine"
131-
132-
\cp -f "../extra/scripts/build.action.sh" "src/shadowbox/docker/build.action.sh"
133-
134-
npm run action shadowbox/docker/build
135-
fi
126+
npm run action shadowbox/docker/build
136127

137128
# Clean-up
138129
cd ..
139130

140131
rm -rf "${TMP}"
141-
rm -rf "${NS_BASE}"
132+
[[ "${AB_LEAVE_BASE_DIRECTORY}" == "" ]] && rm -rf "${NS_BASE}"

extra/scripts/build.action.sh

Lines changed: 0 additions & 40 deletions
This file was deleted.

0 commit comments

Comments
 (0)