Skip to content

Commit

Permalink
feat: healthcheck
Browse files Browse the repository at this point in the history
  • Loading branch information
maxirmx committed Nov 5, 2024
1 parent 936ab4b commit 5ecf3a2
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 11 deletions.
24 changes: 21 additions & 3 deletions docker-compose-ghrc-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,15 @@ services:
- "8080:8080"
- "8081:8081"
depends_on:
- trustvpn-db
- trustvpn-container
trustvpn-db:
condition: service_healthy
trustvpn-container:
condition: service_healthy
healthcheck:
test: ["CMD", "curl", "localhost:8080/api/auth/ststus"]
interval: 10s
timeout: 5s
retries: 2
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- logdata:/app/logs
Expand All @@ -24,6 +31,11 @@ services:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
- POSTGRES_DB=postgres
healthcheck:
test: ["CMD-SHELL", "pg_isready"]
interval: 10s
timeout: 5s
retries: 5
volumes:
- pgdata:/var/lib/postgresql/data

Expand All @@ -38,6 +50,11 @@ services:
sysctls:
- net.ipv6.conf.all.disable_ipv6=0
- net.ipv6.conf.all.forwarding=1
healthcheck:
test: ["CMD", "openvpn-check"]
interval: 10s
timeout: 5s
retries: 2
volumes:
- ovpndata:/etc/openvpn

Expand All @@ -47,7 +64,8 @@ services:
container_name: trustvpn-tests
command: ["run", "/home/trustvpn-tests/postman.json"]
depends_on:
- trustvpn-backend
trustvpn-backend:
condition: service_healthy

volumes:
pgdata: {}
Expand Down
21 changes: 19 additions & 2 deletions docker-compose-ghrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,15 @@ services:
- "8080:8080"
- "8081:8081"
depends_on:
- trustvpn-db
- trustvpn-container
trustvpn-db:
condition: service_healthy
trustvpn-container:
condition: service_healthy
healthcheck:
test: ["CMD", "curl", "localhost:8080/api/auth/ststus"]
interval: 10s
timeout: 5s
retries: 2
volumes:
- /etc/nginx/certificate:/etc/certificate
- /var/run/docker.sock:/var/run/docker.sock
Expand All @@ -31,6 +38,11 @@ services:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
- POSTGRES_DB=postgres
healthcheck:
test: ["CMD-SHELL", "pg_isready"]
interval: 10s
timeout: 5s
retries: 5
volumes:
- /var/o-service/pgdata:/var/lib/postgresql/data

Expand All @@ -45,5 +57,10 @@ services:
sysctls:
- net.ipv6.conf.all.disable_ipv6=0
- net.ipv6.conf.all.forwarding=1
healthcheck:
test: ["CMD", "openvpn-check"]
interval: 10s
timeout: 5s
retries: 2
volumes:
- /var/o-service/ovpn:/etc/openvpn
24 changes: 21 additions & 3 deletions docker-compose-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,15 @@ services:
- "8080:8080"
- "8081:8081"
depends_on:
- trustvpn-db
- trustvpn-container
trustvpn-db:
condition: service_healthy
trustvpn-container:
condition: service_healthy
healthcheck:
test: ["CMD", "curl", "localhost:8080/api/auth/ststus"]
interval: 10s
timeout: 5s
retries: 2
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- logdata:/app/logs
Expand All @@ -25,6 +32,11 @@ services:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
- POSTGRES_DB=postgres
healthcheck:
test: ["CMD-SHELL", "pg_isready"]
interval: 10s
timeout: 5s
retries: 5
volumes:
- pgdata:/var/lib/postgresql/data

Expand All @@ -39,6 +51,11 @@ services:
sysctls:
- net.ipv6.conf.all.disable_ipv6=0
- net.ipv6.conf.all.forwarding=1
healthcheck:
test: ["CMD", "openvpn-check"]
interval: 10s
timeout: 5s
retries: 2
volumes:
- ovpndata:/etc/openvpn

Expand All @@ -48,7 +65,8 @@ services:
container_name: trustvpn-tests
command: ["run", "/home/trustvpn-tests/postman.json"]
depends_on:
- trustvpn-backend
trustvpn-backend:
condition: service_healthy

volumes:
pgdata: {}
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ services:

trustvpn-container:
container_name: trustvpn-container
image: ghcr.io/maxirmx/trustvpn-container:0.2.4
image: ghcr.io/maxirmx/trustvpn-container:latest
command: ["trustvpn-container-if-start", "-u", "localhost"]
ports:
- "1194:1194/udp"
Expand Down
2 changes: 1 addition & 1 deletion trustvpn-backend/Controllers/ProfilesController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public async Task<ActionResult<IEnumerable<Profile>>> GetProfiles()
{
_logger.LogDebug("Get all profiles");
var res = await profileContext.Profiles.ToListAsync();
_logger.LogDebug("Get all profiles returning:\n {res}\n", JsonSerializer.Serialize(res, JOptions.DefaultOptions));
_logger.LogDebug("GetProfiles returning:\n {res}\n", JsonSerializer.Serialize(res, JOptions.DefaultOptions));
return res;
}

Expand Down
2 changes: 1 addition & 1 deletion trustvpn-backend/Data/DbEnsure.cs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public void Ensure(NpgsqlConnection connection)
{
_logger.LogInformation("Initializing database at 0.1.4");
Ensure_0_1_4(connection);
_logger.LogInformation("Database version 0.2.1");
_logger.LogInformation("Database version 0.2.4");
PuVersionUpdate("0.2.1", connection);
}
catch (Exception ex)
Expand Down
4 changes: 4 additions & 0 deletions trustvpn-backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@ WORKDIR /app
EXPOSE 8080
EXPOSE 8081

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

# This stage is used to build the service project
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src

COPY ["trustvpn-backend/trustvpn-backend.csproj", "trustvpn-backend/"]
RUN dotnet restore "./trustvpn-backend/trustvpn-backend.csproj"
COPY . .
Expand All @@ -26,4 +29,5 @@ RUN dotnet publish "./trustvpn-backend.csproj" -c $BUILD_CONFIGURATION -o /app/p
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .

ENTRYPOINT ["dotnet", "trustvpn-backend.dll"]

0 comments on commit 5ecf3a2

Please sign in to comment.