mirror of
https://github.com/storytold/voder-proxy.git
synced 2026-10-18 07:33:13 +00:00
Add github workflow and dockerfile
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
.git
|
||||
.idea/
|
||||
target/
|
||||
|
||||
# Ignore Files
|
||||
*png
|
||||
*pt
|
||||
*pyc
|
||||
*pyo
|
||||
*wav
|
||||
*~
|
||||
@@ -0,0 +1,22 @@
|
||||
name: Publish Docker image to GitHub Package Registry
|
||||
on: push
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
if: github.ref == 'refs/heads/master' # Only on master
|
||||
|
||||
steps:
|
||||
- name: Copy Repo Files
|
||||
uses: actions/checkout@master
|
||||
|
||||
#This Action Emits 2 Variables, IMAGE_SHA_NAME and IMAGE_URL
|
||||
#which you can reference in subsequent steps
|
||||
- name: Publish Docker Image to GPR
|
||||
uses: machine-learning-apps/gpr-docker-publish@master
|
||||
id: docker
|
||||
with:
|
||||
IMAGE_NAME: 'tts-service-proxy'
|
||||
DOCKERFILE_PATH: 'Dockerfile'
|
||||
BUILD_CONTEXT: '.'
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
Generated
+12
-12
@@ -695,6 +695,18 @@ version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e604eb7b43c06650e854be16a2a03155743d3752dd1c943f6829e26b7a36e382"
|
||||
|
||||
[[package]]
|
||||
name = "tts-service-proxy"
|
||||
version = "0.0.1"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"env_logger",
|
||||
"futures",
|
||||
"hyper",
|
||||
"hyper-reverse-proxy",
|
||||
"log",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicase"
|
||||
version = "2.6.0"
|
||||
@@ -710,18 +722,6 @@ version = "0.9.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed"
|
||||
|
||||
[[package]]
|
||||
name = "voder-proxy"
|
||||
version = "0.0.1"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"env_logger",
|
||||
"futures",
|
||||
"hyper",
|
||||
"hyper-reverse-proxy",
|
||||
"log",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "want"
|
||||
version = "0.2.0"
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
[package]
|
||||
name = "voder-proxy"
|
||||
name = "tts-service-proxy"
|
||||
edition = "2018"
|
||||
version = "0.0.1"
|
||||
authors = [
|
||||
@@ -9,7 +9,7 @@ authors = [
|
||||
publish = false
|
||||
|
||||
[[bin]]
|
||||
name = "voder-proxy"
|
||||
name = "tts-service-proxy"
|
||||
path = "src/main.rs"
|
||||
|
||||
[dependencies]
|
||||
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
# Unsure if I want to create minimal images yet that run under Alpine Linux.
|
||||
# I have instructions for that here: https://hub.docker.com/r/echelon/testcontainer/dockerfile
|
||||
FROM ubuntu:xenial as build
|
||||
WORKDIR /tmp
|
||||
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y \
|
||||
build-essential \
|
||||
curl \
|
||||
libssl-dev \
|
||||
libssl1.0.0 \
|
||||
pkg-config
|
||||
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs \
|
||||
| sh -s -- --default-toolchain stable -y
|
||||
|
||||
COPY Cargo.lock .
|
||||
COPY Cargo.toml .
|
||||
COPY src/ ./src
|
||||
|
||||
RUN $HOME/.cargo/bin/cargo fetch
|
||||
|
||||
#RUN LD_LIBRARY_PATH=/usr/lib:${LD_LIBRARY_PATH} $HOME/.cargo/bin/cargo build
|
||||
RUN LD_LIBRARY_PATH=/usr/lib:${LD_LIBRARY_PATH} $HOME/.cargo/bin/cargo build --release
|
||||
|
||||
# Final image
|
||||
FROM ubuntu:xenial
|
||||
WORKDIR /
|
||||
|
||||
#COPY --from=build /tmp/target/debug/tts-service-proxy /
|
||||
COPY --from=build /tmp/target/release/tts-service-proxy /
|
||||
|
||||
# SSL certs are required for crypto
|
||||
COPY --from=build /etc/ssl /etc/ssl
|
||||
|
||||
# Required dynamically linked libraries
|
||||
COPY --from=build /lib/x86_64-linux-gnu/libssl.* /lib/x86_64-linux-gnu/
|
||||
COPY --from=build /lib/x86_64-linux-gnu/libcrypto.* /lib/x86_64-linux-gnu/
|
||||
|
||||
# Make sure all the links resolve
|
||||
RUN ldd tts-service-proxy
|
||||
|
||||
EXPOSE 8080
|
||||
CMD LD_LIBRARY_PATH=/usr/lib /tts-service-proxy
|
||||
|
||||
+6
-3
@@ -50,15 +50,18 @@ fn main() {
|
||||
let addr = ([127, 0, 0, 1], 13900).into();
|
||||
|
||||
// A `Service` is needed for every connection.
|
||||
let make_svc = make_service_fn(|socket: &AddrStream| {
|
||||
let make_svc = make_service_fn(move |socket: &AddrStream| {
|
||||
let remote_addr = socket.remote_addr();
|
||||
let route_a = route_one.clone();
|
||||
let route_b = route_two.clone();
|
||||
|
||||
service_fn(move |req: Request<Body>| { // returns BoxFut
|
||||
|
||||
if req.uri().path().starts_with("/first") {
|
||||
return hyper_reverse_proxy::call(remote_addr.ip(), &route_one, req)
|
||||
return hyper_reverse_proxy::call(remote_addr.ip(), &route_a, req)
|
||||
|
||||
} else if req.uri().path().starts_with("/second") {
|
||||
return hyper_reverse_proxy::call(remote_addr.ip(), &route_two, req)
|
||||
return hyper_reverse_proxy::call(remote_addr.ip(), &route_b, req)
|
||||
|
||||
} else {
|
||||
debug_request(req)
|
||||
|
||||
Reference in New Issue
Block a user