Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wip: function image #1071

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 2 additions & 29 deletions .azure/pipelines/docker-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,37 +90,10 @@ steps:
displayName: 'Hacky Docker build'

- task: Docker@2
displayName: push yngdieng-backend (DockerHub)
displayName: push yngdieng-mono (Aliyun)
inputs:
command: push
repository: ztl8702/yngdieng-backend
containerRegistry: dockerHub
tags: |
ci-$(Build.BuildNumber)

- task: Docker@2
displayName: push yngdieng-backend (Aliyun)
inputs:
command: push
repository: zingzeu/yngdieng-backend
containerRegistry: aliyunContainerRegistry
tags: |
ci-$(Build.BuildNumber)

- task: Docker@2
displayName: push yngdieng-grpc-gateway (DockerHub)
inputs:
command: push
repository: ztl8702/yngdieng-grpc-gateway
containerRegistry: dockerHub
tags: |
ci-$(Build.BuildNumber)

- task: Docker@2
displayName: push yngdieng-grpc-gateway (Aliyun)
inputs:
command: push
repository: zingzeu/yngdieng-grpc-gateway
repository: zingzeu/yngdieng-mono
containerRegistry: aliyunContainerRegistry
tags: |
ci-$(Build.BuildNumber)
31 changes: 31 additions & 0 deletions docker/yngdieng-mono/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# context: /<workspace>/server
FROM mcr.microsoft.com/dotnet/core/sdk:3.1 as builder
RUN mkdir /build
RUN mkdir /out
WORKDIR /build
COPY . /build/
RUN dotnet publish -o /out server/backend/Yngdieng.Backend.csproj

# bazel run //server/gateway:image
FROM bazel/server/gateway:image AS gateway

# Build runtime image
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1

# Install ffmpeg
RUN apt-get update && apt-get install -y ffmpeg

# Copy gateway binary
RUN mkdir -p /app/server/gateway
RUN mkdir -p /app/server/backend
COPY --from=gateway /app/server/gateway /app/server/gateway

# Copy backend binary
COPY --from=builder /out /app/server/backend

ADD https://github.com/just-containers/s6-overlay/releases/download/v2.2.0.1/s6-overlay-amd64-installer /tmp/
RUN chmod +x /tmp/s6-overlay-amd64-installer && /tmp/s6-overlay-amd64-installer /

COPY ./etc /etc

ENTRYPOINT ["/init"]
3 changes: 3 additions & 0 deletions docker/yngdieng-mono/etc/services.d/backend/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh
cd /app/server/backend/
dotnet Yngdieng.Backend.dll --IndexPath=/data/hotswap/ --TtsAudioFolder=/data/tts_audio_wav/
2 changes: 2 additions & 0 deletions docker/yngdieng-mono/etc/services.d/gateway/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/execlineb -P
/app/server/gateway/gateway_image.binary --port=8081 --endpoint=localhost:5002 --network=tcp
9 changes: 5 additions & 4 deletions docker_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ echo $TAG
mkdir -p serverbuild
cp -rf ./server serverbuild/
cp -rf ./thirdparty serverbuild/
cp -rf ./docker/yngdieng-mono/etc serverbuild/

# Server image (just one for now)
docker build -f docker/yngdieng-backend/Dockerfile -t ztl8702/yngdieng-backend:$TAG ./serverbuild
docker tag ztl8702/yngdieng-backend:$TAG $ALIYUN_REPO/yngdieng-backend:$TAG
# All-in-one image (for Functions)
docker build -f docker/yngdieng-mono/Dockerfile -t ztl8702/yngdieng-mono:$TAG ./serverbuild
docker tag ztl8702/yngdieng-mono:$TAG $ALIYUN_REPO/yngdieng-mono:$TAG

rm -rf serverbuild
rm -rf serverbuild
7 changes: 7 additions & 0 deletions docker_run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

docker run --rm \
-v $PWD/output:/data/hotswap:ro \
-p 5000:80 \
-p 5001:8081 \
ztl8702/yngdieng-mono:latest
2 changes: 1 addition & 1 deletion server/backend/Yngdieng.Backend.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Aliyun.OSS.SDK.NetCore" Version="2.12.0" />
<PackageReference Include="Aliyun.OSS.SDK.NetCore" Version="2.13.0" />
<PackageReference Include="EFCore.NamingConventions" Version="1.1.0" />
<PackageReference Include="Grpc.AspNetCore" Version="2.34.0" />
<PackageReference Include="Grpc.AspNetCore.Server.Reflection" Version="2.34.0" />
Expand Down
10 changes: 2 additions & 8 deletions server/backend/appsettings.Production.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,11 @@
"Endpoints": {
"Http": {
"Url": "http://*:80",
"Protocols": "Http1AndHttp2"
"Protocols": "Http1"
},
"InsecureHttp2": {
"Url": "http://*:8080",
"Url": "http://localhost:5002",
"Protocols": "Http2"
},
"HttpsCustomCert": {
"Url": "https://*:443",
"Certificate": {
"Path": "/data/hotswap/cert.pfx"
}
}
}
}
Expand Down