diff --git a/api/Dockerfile b/api/Dockerfile index 246595b73..d841eb47a 100644 --- a/api/Dockerfile +++ b/api/Dockerfile @@ -52,6 +52,8 @@ RUN poetry install --no-root --with dev COPY . /api +COPY --from=ghcr.io/tarampampam/curl:8.1.1 /bin/curl /bin/curl + # Set the host to 0.0.0.0 to make the server available external # to the Docker container that it's running in. ENV HOST=0.0.0.0 @@ -98,6 +100,8 @@ RUN poetry install --no-root --only main # or the application will not build RUN poetry build --format wheel && poetry run pip install 'dist/grants_equity_api-0.1.0-py3-none-any.whl' +COPY --from=ghcr.io/tarampampam/curl:8.1.1 /bin/curl /bin/curl + # Add project's virtual env to the PATH so we can directly run poetry scripts # defiend in pyproject.toml ENV PATH="/api/.venv/bin:$PATH" diff --git a/docker-compose.yml b/docker-compose.yml index 5311961d7..5fcdfa5f7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -46,6 +46,23 @@ services: restart: always ports: - 3000:3000 + healthcheck: + # CMD-SHELL runs on the default shell client, ie /bin/sh + # CMD runs the command directly + test: ["CMD", + "curl", + "--fail", + "-sLo", + "/dev/null", + "-w", + "%{http_code}", + "http://localhost:3000/health" + ] + interval: 60s + timeout: 5s + retries: 3 + start_period: 20s + storybook: container_name: storybook diff --git a/frontend/Dockerfile b/frontend/Dockerfile index 26f5863ec..c8ce85a2a 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -23,6 +23,8 @@ COPY src ./src COPY stories ./stories COPY .storybook ./.storybook +COPY --from=ghcr.io/tarampampam/curl:8.1.1 /bin/curl /bin/curl + ENV NEXT_TELEMETRY_DISABLED 1 CMD ["npm", "run", "dev"] @@ -86,6 +88,8 @@ RUN adduser --system --uid 1001 nextjs RUN chown nextjs:nodejs /frontend/.next/cache/images/ USER nextjs +COPY --from=ghcr.io/tarampampam/curl:8.1.1 /bin/curl /bin/curl + COPY --from=builder /frontend/public ./public # Automatically leverage output traces to reduce image size diff --git a/infra/modules/service/main.tf b/infra/modules/service/main.tf index 9eca27e4c..971318dca 100644 --- a/infra/modules/service/main.tf +++ b/infra/modules/service/main.tf @@ -80,8 +80,14 @@ resource "aws_ecs_task_definition" "app" { interval = 30, retries = 3, timeout = 5, - command = ["CMD-SHELL", - "wget --no-verbose --tries=1 --spider http://localhost:${var.container_port}/health || exit 1" + command = ["CMD", + "curl", + "--fail", + "-sLo", + "/dev/null", + "-w", + "%%{http_code}", + "http://localhost:8000/health" ] }, environment = local.environment_variables,