-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: better logging and fix deployment (#150)
* feat: better logging and fix deployment * fix tests * remove comment --------- Co-authored-by: Natoandro <anatoandro@hotmail.com>
- Loading branch information
Showing
45 changed files
with
475 additions
and
322 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,74 +1,91 @@ | ||
ARG RUST_VERSION=1.67.1 | ||
ARG DENO_VERSION=1.30.3 | ||
ARG DISTROLESS_TAG=nonroot | ||
|
||
FROM lukemathwalker/cargo-chef:latest-rust-${RUST_VERSION} AS base | ||
|
||
WORKDIR / | ||
WORKDIR /app | ||
|
||
# | ||
|
||
FROM base as plan | ||
|
||
COPY . . | ||
RUN rm -rf meta-cli \ | ||
&& cargo new meta-cli \ | ||
&& cargo chef prepare --recipe-path recipe.json | ||
|
||
RUN cargo chef prepare --recipe-path recipe.json | ||
|
||
# | ||
|
||
FROM denoland/deno:bin-${DENO_VERSION} AS deno-bin | ||
|
||
# | ||
|
||
FROM base AS builder | ||
|
||
ARG DENO_VERSION=1.30.3 | ||
ARG DENO_BINDGEN_URL=https://github.com/denoland/deno_bindgen/raw/main/cli.ts | ||
|
||
ENV DENO_DIR /deno-dir/ | ||
ENV DENO_INSTALL /root/.deno | ||
ENV PATH "${DENO_INSTALL}/bin:${PATH}" | ||
ENV OUT_DIR target | ||
|
||
COPY --from=deno-bin /deno /bin/deno | ||
|
||
RUN apt-get update \ | ||
&& apt-get install -y \ | ||
&& apt-get install -y --no-install-recommends \ | ||
protobuf-compiler \ | ||
libprotobuf-dev \ | ||
&& rm -rf /var/lib/apt/lists/* \ | ||
&& curl -fsSL https://deno.land/x/install/install.sh -o install.sh \ | ||
&& sh ./install.sh v${DENO_VERSION} \ | ||
&& deno install -Afq -n deno_bindgen $DENO_BINDGEN_URL | ||
|
||
COPY --from=plan /recipe.json recipe.json | ||
RUN cargo chef cook --release --recipe-path recipe.json | ||
COPY --from=plan /app/recipe.json recipe.json | ||
|
||
RUN cargo chef cook --recipe-path recipe.json --release --package native --features deno | ||
|
||
COPY . . | ||
RUN OUT_DIR=target deno_bindgen --release -- --locked --package native -F deno \ | ||
&& mv /target/release/libnative.so . | ||
|
||
WORKDIR /typegate | ||
RUN deno cache --config=deno.json --unstable src/main.ts \ | ||
&& mkdir tmp | ||
RUN deno_bindgen --release -- --locked --package native --features deno \ | ||
&& mv /app/target/release/libnative.so . | ||
|
||
WORKDIR /app/typegate | ||
|
||
RUN deno cache --unstable src/main.ts \ | ||
&& mkdir -p tmp | ||
|
||
# | ||
|
||
FROM debian:stable-slim AS debian | ||
|
||
ARG TINI_VERSION=v0.19.0 | ||
|
||
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini | ||
|
||
RUN chmod +x /tini | ||
|
||
# | ||
|
||
FROM denoland/deno:distroless-${DENO_VERSION} AS runner | ||
FROM gcr.io/distroless/cc-debian11:${DISTROLESS_TAG} | ||
|
||
ENV DENO_DIR /deno-dir/ | ||
|
||
WORKDIR /app | ||
|
||
COPY --from=debian /tini /tini | ||
COPY --from=deno-bin /deno /bin/deno | ||
COPY --from=debian /lib/x86_64-linux-gnu/libz.so* /lib/x86_64-linux-gnu/ | ||
COPY LICENSE.md . | ||
COPY --from=builder /bindings/bindings.ts /bindings/ | ||
COPY --from=builder /libnative.so /target/release/ | ||
COPY --from=builder /typegate/deno.json ./ | ||
COPY --from=builder /typegate/src ./src | ||
COPY --from=builder /app/bindings/bindings.ts /bindings/ | ||
COPY --from=builder /app/libnative.so /target/release/ | ||
COPY --from=builder /app/typegate/deno.json ./ | ||
COPY --from=builder /app/typegate/src ./src | ||
|
||
# writeable | ||
COPY --from=builder --chown=nonroot:nonroot /deno-dir /deno-dir | ||
COPY --from=builder --chown=nonroot:nonroot /typegate/deno.lock ./ | ||
COPY --from=builder --chown=nonroot:nonroot /typegate/tmp ./ | ||
COPY --from=builder --chown=nonroot:nonroot /app/typegate/deno.lock ./ | ||
COPY --from=builder --chown=nonroot:nonroot /app/typegate/tmp ./ | ||
|
||
USER nonroot | ||
EXPOSE 7890 | ||
|
||
ENTRYPOINT ["/tini", "--"] | ||
|
||
CMD ["deno", "run", "--config=deno.json", "--unstable", "--allow-run=hostname", "--allow-env", "--allow-hrtime", "--allow-write", "--allow-ffi", "--allow-read", "--allow-net", "src/main.ts"] | ||
ENTRYPOINT ["/tini", "--", "/bin/deno"] | ||
CMD ["run", "--unstable", "--allow-run=hostname", "--allow-env", "--allow-hrtime", "--allow-write", "--allow-ffi", "--allow-read", "--allow-net", "src/main.ts"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ website | |
bindings | ||
examples | ||
**/.* | ||
tmp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 7 additions & 7 deletions
14
...blog/20221207134232_init_db/migration.sql → ...og/blog/20230223181908_init/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.