Skip to content

Commit

Permalink
feat: switch to rustls to avoid compiling OpenSSL and relying on loca…
Browse files Browse the repository at this point in the history
…l certs
  • Loading branch information
Angelmmiguel committed Nov 24, 2023
1 parent 641d773 commit 4597a02
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 34 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/artifacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ jobs:
platform: unknown-linux-musl
cross: false
name: linux-musl
features: --features vendored-openssl
features:
- build: linux
arch: aarch64
os: ubuntu-latest
platform: unknown-linux-musl
cross: true
name: linux-musl
features: --features vendored-openssl
features:
- build: windows
arch: x86_64
os: windows-latest
Expand Down Expand Up @@ -53,7 +53,7 @@ jobs:
platform: apple-darwin
cross: false
name: macos-darwin
features: --features vendored-openssl
features:
runs-on: ${{ matrix.os }}
env:
# This variable can be overriden with `cross` for builds that
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/container-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
sudo apt-get update
sudo apt-get install musl-tools
- name: Build
run: ${{env.CARGO}} build --release --target=${{ matrix.arch }}-${{ matrix.platform }} --features vendored-openssl
run: ${{env.CARGO}} build --release --target=${{ matrix.arch }}-${{ matrix.platform }}
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/container-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
sudo apt-get update
sudo apt-get install musl-tools
- name: Build
run: ${{env.CARGO}} build --release --target=${{ matrix.arch }}-${{ matrix.platform }} --features vendored-openssl
run: ${{env.CARGO}} build --release --target=${{ matrix.arch }}-${{ matrix.platform }}
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
Expand Down
70 changes: 59 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ wws_config = []
wws_router = []
wws_server = []

vendored-openssl = ["wws-project/vendored-openssl"]

[workspace]
members = [
"crates/api-manage",
Expand Down Expand Up @@ -77,7 +75,7 @@ exclude = [
[workspace.dependencies]
actix-web = "4"
lazy_static = "1.4.0"
reqwest = "0.11"
reqwest = { version = "0.11", features = ["rustls"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0.85"
tokio = "1.28"
Expand All @@ -99,4 +97,3 @@ wasmtime-wasi = "13.0.0"
wasmtime-wasi-nn = "13.0.0"
wasi-common = "13.0.0"
path-slash = "0.2.1"
openssl = { version = "=0.10.55" }
5 changes: 0 additions & 5 deletions crates/project/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@ wws-store = { workspace = true }
url = "2.3.1"
sha256 = "1.1.1"
git2 = "0.17.2"
# Not all platforms require OpenSSL
openssl = { workspace = true, optional = true }

[features]
vendored-openssl = ["openssl/vendored"]

[dev-dependencies]
path-slash = { workspace = true }
8 changes: 2 additions & 6 deletions image/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# Build wasm_runtime in release mode


FROM --platform=$TARGETPLATFORM rust:1.71.0-slim as build-wws
ARG WWS_BUILD_DIR=/usr/src/wws
ARG TARGETPLATFORM
Expand All @@ -19,15 +17,13 @@ RUN set -eux; \
*) echo >&2 "unsupported architecture: $BUILDPLATFORM"; exit 1 ;; \
esac; \
rustup target add $bldArch; \
cargo build --release --features vendored-openssl --target=$bldArch; \
cargo build --release --target=$bldArch; \
mkdir ./build; \
cp ./target/$bldArch/release/wws ./build/wws


# Build the image
FROM --platform=$TARGETPLATFORM debian:bullseye-slim
ARG WWS_BUILD_DIR=/usr/src/wws
RUN apt-get update && \
apt-get install -y --no-install-recommends ca-certificates
RUN mkdir -p /app
RUN mkdir -p /opt
COPY --from=build-wws ${WWS_BUILD_DIR}/build/wws /opt
Expand Down
4 changes: 1 addition & 3 deletions image/Prebuilt.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
# is mainly used to build the preview / release container images in
# GitHub actions

# Retrieve the certificates to install runtimes later on.
# Create the folders for the main container
FROM --platform=$TARGETPLATFORM bitnami/minideb:latest AS sysroot
RUN mkdir -p /target/app /target/opt
RUN install_packages ca-certificates

# Build the final image
FROM --platform=$TARGETPLATFORM scratch
Expand All @@ -17,7 +16,6 @@ LABEL org.opencontainers.image.licenses="Apache-2.0"

COPY --from=sysroot /target/app /app
COPY --from=sysroot /target/opt /opt
COPY --from=sysroot /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --chmod=755 ./wws-$TARGETARCH /opt/wws

ENTRYPOINT ["/opt/wws"]
Expand Down

0 comments on commit 4597a02

Please sign in to comment.