add healthchecks to docker

This commit is contained in:
rootdarkarchon
2023-01-02 02:50:33 +01:00
parent 7f49ca8627
commit bdd8830c8e
9 changed files with 40 additions and 13 deletions

View File

@@ -24,6 +24,7 @@ RUN adduser \
COPY --from=BUILD /build /opt/MareSynchronosServer
RUN chown -R mare:mare /opt/MareSynchronosServer
RUN apt-get update; apt-get install curl -y
USER mare:mare
WORKDIR /opt/MareSynchronosServer

View File

@@ -22,6 +22,7 @@ RUN adduser \
COPY --from=BUILD /MareSynchronosServer /opt/MareSynchronosServer
RUN chown -R mare:mare /opt/MareSynchronosServer
RUN apt-get update; apt-get install curl -y
USER mare:mare
WORKDIR /opt/MareSynchronosServer

View File

@@ -24,6 +24,7 @@ RUN adduser \
COPY --from=BUILD /build /opt/MareSynchronosServices
RUN chown -R mare:mare /opt/MareSynchronosServices
RUN apt-get update; apt-get install curl -y
USER mare:mare
WORKDIR /opt/MareSynchronosServices

View File

@@ -22,6 +22,7 @@ RUN adduser \
COPY --from=BUILD /MareSynchronosServices /opt/MareSynchronosServices
RUN chown -R mare:mare /opt/MareSynchronosServices
RUN apt-get update; apt-get install curl -y
USER mare:mare
WORKDIR /opt/MareSynchronosServices

View File

@@ -24,6 +24,7 @@ RUN adduser \
COPY --from=BUILD /build /opt/MareSynchronosStaticFilesServer
RUN chown -R mare:mare /opt/MareSynchronosStaticFilesServer
RUN apt-get update; apt-get install curl -y
USER mare:mare
WORKDIR /opt/MareSynchronosStaticFilesServer

View File

@@ -22,6 +22,7 @@ RUN adduser \
COPY --from=BUILD /MareSynchronosStaticFilesServer /opt/MareSynchronosStaticFilesServer
RUN chown -R mare:mare /opt/MareSynchronosStaticFilesServer
RUN apt-get update; apt-get install curl -y
USER mare:mare
WORKDIR /opt/MareSynchronosStaticFilesServer

View File

@@ -12,6 +12,7 @@ services:
healthcheck:
test: ["CMD-SHELL", "pg_isready -U mare"]
interval: 5s
start_period: 5s
timeout: 5s
retries: 5
@@ -22,7 +23,10 @@ services:
- 6000:6000/tcp
volumes:
- ../config/sharded/haproxy-shards.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro
depends_on:
mare-server:
condition: service_healthy
redis:
image: redis:latest
command: [sh, -c, "rm -f /data/dump.rdb && redis-server --save \"\" --appendonly no --requirepass secretredispassword"]
@@ -45,6 +49,11 @@ services:
depends_on:
postgres:
condition: service_healthy
healthcheck:
test: ["CMD-SHELL", "curl --fail http://localhost:6000/health || exit 1"]
retries: 60
start_period: 10s
timeout: 1s
mare-shard-1:
image: darkarchon/mare-synchronos-server:latest
@@ -54,8 +63,8 @@ services:
- ../log/server-shard-1/:/opt/MareSynchronosServer/logs/:rw
- postgres_socket:/var/run/postgresql/:rw
depends_on:
- "postgres"
- "mare-server"
mare-server:
condition: service_healthy
mare-shard-2:
image: darkarchon/mare-synchronos-server:latest
@@ -65,8 +74,8 @@ services:
- ../log/server-shard-2/:/opt/MareSynchronosServer/logs/:rw
- postgres_socket:/var/run/postgresql/:rw
depends_on:
- "postgres"
- "mare-server"
mare-server:
condition: service_healthy
mare-services:
image: darkarchon/mare-synchronos-services:latest
@@ -78,8 +87,8 @@ services:
- ../log/services-standalone/:/opt/MareSynchronosServices/logs/:rw
- postgres_socket:/var/run/postgresql/:rw
depends_on:
- "postgres"
- "mare-server"
mare-server:
condition: service_healthy
mare-files:
image: darkarchon/mare-synchronos-staticfilesserver:latest
@@ -90,8 +99,13 @@ services:
- postgres_socket:/var/run/postgresql/:rw
- ../data/files-shard-main/:/marecache/:rw
depends_on:
- "postgres"
- "mare-server"
mare-server:
condition: service_healthy
healthcheck:
test: curl --fail http://localhost:6200/health || exit 1
retries: 60
start_period: 10s
timeout: 1s
mare-files-shard-1:
image: darkarchon/mare-synchronos-staticfilesserver:latest
@@ -104,8 +118,8 @@ services:
ports:
- 6200:6200/tcp
depends_on:
- "postgres"
- "mare-files"
mare-files:
condition: service_healthy
mare-files-shard-2:
image: darkarchon/mare-synchronos-staticfilesserver:latest
@@ -118,8 +132,8 @@ services:
ports:
- 6201:6200/tcp
depends_on:
- "postgres"
- "mare-files"
mare-files:
condition: service_healthy
volumes:
cache:

View File

@@ -60,6 +60,8 @@ public class Startup
// configure mare specific services
ConfigureMareServices(services, mareConfig);
services.AddHealthChecks();
}
private static void ConfigureMareServices(IServiceCollection services, IConfigurationSection mareConfig)
@@ -303,6 +305,8 @@ public class Startup
endpoints.MapGrpcService<GrpcIdentityService>().AllowAnonymous();
endpoints.MapGrpcService<GrpcConfigurationService<ServerConfiguration>>().AllowAnonymous();
}
endpoints.MapHealthChecks("/health").WithMetadata(new AllowAnonymousAttribute());
});
}
}

View File

@@ -136,6 +136,8 @@ public class Startup
);
services.AddHostedService(p => (MareConfigurationServiceClient<MareConfigurationAuthBase>)p.GetService<IConfigurationService<MareConfigurationAuthBase>>());
services.AddHealthChecks();
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
@@ -161,6 +163,7 @@ public class Startup
e.MapGrpcService<GrpcFileService>();
}
e.MapControllers();
e.MapHealthChecks("/health").WithMetadata(new AllowAnonymousAttribute());
});
}
}