Skip to content

Commit

Permalink
minor updates for cartservice (GoogleCloudPlatform#481)
Browse files Browse the repository at this point in the history
* ASPNETCORE_URLS in Dockerfile

* GRPC_HEALTH_PROBE_VERSION=v0.3.6

* Grpc.AspNetCore - 2.34.0

* more for dockerignore

* typo

* remove unused files

* c# 9 syntax improvement with Program.cs
  • Loading branch information
mathieu-benoit authored Jan 11, 2021
1 parent 8f6c1f7 commit 7a2a0d7
Show file tree
Hide file tree
Showing 17 changed files with 26 additions and 144 deletions.
2 changes: 0 additions & 2 deletions kubernetes-manifests/cartservice.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ spec:
env:
- name: REDIS_ADDR
value: "redis-cart:6379"
- name: ASPNETCORE_URLS
value: "http://0.0.0.0:7070"
resources:
requests:
cpu: 200m
Expand Down
2 changes: 1 addition & 1 deletion src/adservice/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ RUN mkdir -p /opt/cprof && \
| tar xzv -C /opt/cprof && \
rm -rf profiler_java_agent.tar.gz

RUN GRPC_HEALTH_PROBE_VERSION=v0.3.5 && \
RUN GRPC_HEALTH_PROBE_VERSION=v0.3.6 && \
wget -qO/bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-amd64 && \
chmod +x /bin/grpc_health_probe

Expand Down
4 changes: 4 additions & 0 deletions src/cartservice/.dockerignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
**/*.sh
**/*.bat
tests/
**/bin/
**/obj/
**/out/
Dockerfile*
3 changes: 2 additions & 1 deletion src/cartservice/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ RUN dotnet publish cartservice.csproj -p:PublishSingleFile=true -r linux-musl-x6

# https://mcr.microsoft.com/v2/dotnet/runtime-deps/tags/list
FROM mcr.microsoft.com/dotnet/runtime-deps:5.0.1-alpine3.12-amd64
RUN GRPC_HEALTH_PROBE_VERSION=v0.3.5 && \
RUN GRPC_HEALTH_PROBE_VERSION=v0.3.6 && \
wget -qO/bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-amd64 && \
chmod +x /bin/grpc_health_probe
WORKDIR /app
COPY --from=builder /cartservice .
ENV ASPNETCORE_URLS http://*:7070
ENTRYPOINT ["/app/cartservice"]
27 changes: 8 additions & 19 deletions src/cartservice/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,15 @@
// See the License for the specific language governing permissions and
// limitations under the License.

using System;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;
using cartservice;

namespace cartservice
{
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
CreateHostBuilder(args).Build().Run();

// Additional configuration is required to successfully run gRPC on macOS.
// For instructions on how to configure Kestrel and gRPC clients on macOS, visit https://go.microsoft.com/fwlink/?linkid=2099682
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
}
}
static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
2 changes: 1 addition & 1 deletion src/cartservice/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public void ConfigureServices(IServiceCollection services)
else
{
Console.WriteLine("Redis cache host(hostname+port) was not specified. Starting a cart service using local store");
Console.WriteLine("If you wanted to use Redis Cache as a backup store, you should provide its address via command line or REDIS_ADDRESS environment variable.");
Console.WriteLine("If you wanted to use Redis Cache as a backup store, you should provide its address via command line or REDIS_ADDR environment variable.");
cartStore = new LocalCartStore();
}

Expand Down
4 changes: 2 additions & 2 deletions src/cartservice/cartservice.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Grpc.AspNetCore" Version="2.33.1" />
<PackageReference Include="Grpc.HealthCheck" Version="2.33.1" />
<PackageReference Include="Grpc.AspNetCore" Version="2.34.0" />
<PackageReference Include="Grpc.HealthCheck" Version="2.34.0" />
<PackageReference Include="StackExchange.Redis" Version="2.2.4" />
</ItemGroup>

Expand Down
20 changes: 0 additions & 20 deletions src/cartservice/scripts/build_image.bat

This file was deleted.

65 changes: 0 additions & 65 deletions src/cartservice/scripts/docker_setup.bat

This file was deleted.

25 changes: 0 additions & 25 deletions src/cartservice/scripts/run_redis_emulator_windows.bat

This file was deleted.

4 changes: 2 additions & 2 deletions src/cartservice/tests/cartservice.tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Grpc.AspNetCore" Version="2.33.1" />
<PackageReference Include="Grpc.Tools" Version="2.33.1" />
<PackageReference Include="Grpc.AspNetCore" Version="2.34.0" />
<PackageReference Include="Grpc.Tools" Version="2.34.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.3" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" />
Expand Down
2 changes: 1 addition & 1 deletion src/checkoutservice/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ RUN go build -gcflags='-N -l' -o /checkoutservice .

FROM alpine as release
RUN apk add --no-cache ca-certificates
RUN GRPC_HEALTH_PROBE_VERSION=v0.3.5 && \
RUN GRPC_HEALTH_PROBE_VERSION=v0.3.6 && \
wget -qO/bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-amd64 && \
chmod +x /bin/grpc_health_probe
COPY --from=builder /checkoutservice /checkoutservice
Expand Down
2 changes: 1 addition & 1 deletion src/currencyservice/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ RUN npm install --only=production

FROM base

RUN GRPC_HEALTH_PROBE_VERSION=v0.3.5 && \
RUN GRPC_HEALTH_PROBE_VERSION=v0.3.6 && \
wget -qO/bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-amd64 && \
chmod +x /bin/grpc_health_probe

Expand Down
2 changes: 1 addition & 1 deletion src/emailservice/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ RUN apt-get -qq update \
wget

# Download the grpc health probe
RUN GRPC_HEALTH_PROBE_VERSION=v0.3.5 && \
RUN GRPC_HEALTH_PROBE_VERSION=v0.3.6 && \
wget -qO/bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-amd64 && \
chmod +x /bin/grpc_health_probe

Expand Down
2 changes: 1 addition & 1 deletion src/paymentservice/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ RUN npm install --only=production

FROM base

RUN GRPC_HEALTH_PROBE_VERSION=v0.3.5 && \
RUN GRPC_HEALTH_PROBE_VERSION=v0.3.6 && \
wget -qO/bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-amd64 && \
chmod +x /bin/grpc_health_probe

Expand Down
2 changes: 1 addition & 1 deletion src/productcatalogservice/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ RUN go build -o /productcatalogservice .

FROM alpine AS release
RUN apk add --no-cache ca-certificates
RUN GRPC_HEALTH_PROBE_VERSION=v0.3.5 && \
RUN GRPC_HEALTH_PROBE_VERSION=v0.3.6 && \
wget -qO/bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-amd64 && \
chmod +x /bin/grpc_health_probe
WORKDIR /productcatalogservice
Expand Down
2 changes: 1 addition & 1 deletion src/recommendationservice/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ RUN apt-get update -qqy && \
ENV PYTHONUNBUFFERED=0

# download the grpc health probe
RUN GRPC_HEALTH_PROBE_VERSION=v0.3.5 && \
RUN GRPC_HEALTH_PROBE_VERSION=v0.3.6 && \
wget -qO/bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-amd64 && \
chmod +x /bin/grpc_health_probe

Expand Down

0 comments on commit 7a2a0d7

Please sign in to comment.