Skip to content

Commit 6fed895

Browse files
committed
fix: workflows
Signed-off-by: zu1k <[email protected]>
1 parent 9a65a98 commit 6fed895

6 files changed

Lines changed: 100 additions & 8 deletions

File tree

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Build Docker Images
2+
on:
3+
release:
4+
types: [published]
5+
6+
jobs:
7+
build:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Checkout
11+
uses: actions/checkout@v2
12+
- name: Setup Docker Buildx
13+
uses: docker/setup-buildx-action@v1
14+
- name: Login to GitHub Container Registry
15+
uses: docker/login-action@v1
16+
with:
17+
registry: ghcr.io
18+
username: ${{ github.repository_owner }}
19+
password: ${{ secrets.GITHUB_TOKEN }}
20+
- name: Docker metadata
21+
id: metadata
22+
uses: docker/metadata-action@v3
23+
with:
24+
images: ghcr.io/${{ github.repository_owner }}/good-mitm
25+
- name: Build and release Docker images
26+
uses: docker/build-push-action@v2
27+
with:
28+
platforms: linux/amd64,linux/arm64/v8
29+
target: good-mitm
30+
tags: ${{ steps.metadata.outputs.tags }}
31+
push: true

.github/workflows/build-release.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ jobs:
4343

4444
- name: Build ${{ matrix.target }}
4545
timeout-minutes: 120
46+
env:
47+
PKG_CONFIG_ALLOW_CROSS: "1"
4648
run: |
4749
compile_target=${{ matrix.target }}
4850
@@ -76,11 +78,10 @@ jobs:
7678
steps:
7779
- uses: actions/checkout@v2
7880

79-
- name: Install GNU tar
81+
- name: Install Dependences
8082
if: runner.os == 'macOS'
8183
run: |
82-
brew install gnu-tar
83-
# echo "::add-path::/usr/local/opt/gnu-tar/libexec/gnubin"
84+
brew install gnu-tar pkg-config openssl
8485
echo "/usr/local/opt/gnu-tar/libexec/gnubin" >> $GITHUB_PATH
8586
8687
- name: Install Rust

Cargo.lock

Lines changed: 14 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cross.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[build]
2+
pre-build = [
3+
"dpkg --add-architecture $CROSS_DEB_ARCH",
4+
"apt-get update && apt-get --assume-yes install pkg-config:$CROSS_DEB_ARCH libssl-dev:$CROSS_DEB_ARCH"
5+
]
6+
7+
[build.env]
8+
passthrough = [
9+
"RUST_BACKTRACE",
10+
"RUST_LOG",
11+
"PKG_CONFIG_ALLOW_CROSS"
12+
]

Dockerfile

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
FROM --platform=$BUILDPLATFORM rust:1.61.0-buster AS build
2+
3+
ARG TARGETARCH
4+
5+
RUN apt-get update && apt-get install -y build-essential curl musl-tools upx pkg-config libssl-dev
6+
7+
WORKDIR /root/good-mitm
8+
9+
ADD . .
10+
11+
RUN rustup install nightly && rustup default nightly && \
12+
case "$TARGETARCH" in \
13+
"amd64") \
14+
RUST_TARGET="x86_64-unknown-linux-musl" \
15+
MUSL="x86_64-linux-musl" \
16+
;; \
17+
"arm64") \
18+
RUST_TARGET="aarch64-unknown-linux-musl" \
19+
MUSL="aarch64-linux-musl" \
20+
;; \
21+
*) \
22+
echo "Doesn't support $TARGETARCH architecture" \
23+
exit 1 \
24+
;; \
25+
esac && \
26+
wget -qO- "https://musl.cc/$MUSL-cross.tgz" | tar -xzC /root/ && \
27+
CC=/root/$MUSL-cross/bin/$MUSL-gcc && \
28+
rustup target add $RUST_TARGET && \
29+
PKG_CONFIG_ALLOW_CROSS=1 RUSTFLAGS="-C linker=$CC" CC=$CC cargo build --target "$RUST_TARGET" --release && \
30+
mv target/$RUST_TARGET/release/good-mitm target/release/ && \
31+
upx -9 target/release/good-mitm
32+
33+
FROM alpine:3.14 AS good-mitm
34+
35+
COPY --from=build /root/good-mitm/target/release/good-mitm /usr/bin
36+
ENTRYPOINT [ "good-mitm" ]

core/Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "good-mitm-core"
3-
version = "0.1.0"
3+
version = "0.1.1"
44
edition = "2021"
55
description = "Use MITM technology to provide features like rewrite, redirect."
66
homepage = "https://github.com/zu1k/good-mitm"
@@ -21,6 +21,7 @@ hyper-rustls = { version = "0.23" }
2121
hyper-tls = { version = "0.5", optional = true }
2222
log = "0.4"
2323
moka = { version = "0.8", features = ["future"] }
24+
openssl = { version = "0.10", features = ["vendored"], optional = true }
2425
rcgen = { version = "0.9", features = ["x509-parser"] }
2526
serde = { version = "1.0", features = ["derive"] }
2627
thiserror = "1"
@@ -36,5 +37,5 @@ rand = "0.8.5"
3637

3738
[features]
3839
default = ["h2", "request-native-tls"]
39-
request-native-tls = ["hyper-tls"]
40+
request-native-tls = ["hyper-tls", "openssl"]
4041
h2 = ["hyper-rustls/http2"]

0 commit comments

Comments
 (0)