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

Refactor docker-related configuration #80

Merged
merged 1 commit into from
Jul 4, 2024
Merged
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
12 changes: 6 additions & 6 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ ARG BASE_IMAGE=python:3.12.1-alpine3.19
###########################################################
# Tools stage
###########################################################
FROM --platform=linux/amd64 ${BASE_IMAGE} AS tools
FROM ${BASE_IMAGE} AS tools

# Install curl
RUN apk add --no-cache curl
RUN apk add --no-cache curl musl-dev libffi-dev gcc

# Download waitforit
RUN curl -o /usr/local/bin/waitforit -sSL https://github.com/maxcnunes/waitforit/releases/download/v2.4.1/waitforit-linux_amd64 && \
RUN curl -o /usr/local/bin/waitforit -sSL https://github.com/maxcnunes/waitforit/releases/download/v2.4.1/waitforit-linux_${TARGETARCH} && \
chmod +x /usr/local/bin/waitforit

# Download poetry
Expand All @@ -21,7 +21,7 @@ RUN curl -sSL https://install.python-poetry.org | python
###########################################################
# Base stage
###########################################################
FROM --platform=linux/amd64 ${BASE_IMAGE} AS base
FROM ${BASE_IMAGE} AS base

# Install runtime dependencies
RUN apk add --no-cache bash libpq
Expand All @@ -36,8 +36,8 @@ COPY --from=tools /usr/local/bin/waitforit /usr/local/bin/waitforit
WORKDIR /src

# Copy and set entrypoint script
COPY --chmod=755 docker-entrypoint.sh /usr/local/bin/
ENTRYPOINT ["docker-entrypoint.sh"]
COPY --chmod=755 entrypoint.sh /usr/local/bin/
ENTRYPOINT ["entrypoint.sh"]


###########################################################
Expand Down
File renamed without changes.
54 changes: 39 additions & 15 deletions docker-compose.yml → compose.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,32 @@
version: '3.9'

volumes:
postgres_data:
fusionauth_config:
postgres-data:
fusionauth-config:

services:
proxy:
image: tivix/docker-nginx:v17
image: tivix/docker-nginx:v18
restart: unless-stopped
depends_on:
- frontend
- fusionauth
- api-server
frontend:
condition: service_healthy
fusionauth:
condition: service_healthy
api-server:
condition: service_healthy
ports:
- "8080:80"
environment:
- UPSTREAMS=/api:fusionauth:9011,/cpf/api:api-server:8000,/:frontend:3000
- WEBSOCKETS=true

- HEALTHCHECK=/health
- HEALTHCHECK_PORT=8888
- HEALTHCHECK_LISTEN=0.0.0.0
healthcheck:
test: wget -q -O /dev/null http://proxy:8888/health
interval: 5s
timeout: 5s
retries: 5

frontend:
restart: unless-stopped
stdin_open: true
Expand All @@ -28,9 +37,14 @@ services:
- ./frontend/src:/code/src
- ./frontend/public:/code/public
ports:
- '3000:3000'
- "3000:3000"
env_file:
- .env
healthcheck: # TODO: /health once available
test: wget -q -O /dev/null http://frontend:3000/auth
interval: 5s
timeout: 5s
retries: 5

api-server:
image: cpf/backend-image
Expand All @@ -47,8 +61,18 @@ services:
- ./backend/src:/src
stdin_open: true
tty: true
depends_on:
data-loader:
condition: service_completed_successfully
fusionauth:
condition: service_healthy
healthcheck:
test: wget -q -O /dev/null http://api-server:8000/cpf/api/health
interval: 5s
timeout: 5s
retries: 5

data_loader:
data-loader:
image: cpf/backend-image
restart: "no"
build:
Expand All @@ -72,14 +96,14 @@ services:
env_file:
- .env
healthcheck:
test: [ "CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d postgres" ]
test: pg_isready -U ${POSTGRES_USER} -d postgres
interval: 5s
timeout: 5s
retries: 5
ports:
- "5432:5432"
volumes:
- postgres_data:/var/lib/postgresql/data/
- postgres-data:/var/lib/postgresql/data/

fusionauth:
image: fusionauth/fusionauth-app:1.48.3
Expand All @@ -103,10 +127,10 @@ services:
postgres:
condition: service_healthy
healthcheck:
test: curl --silent --fail http://localhost:9011/api/status -o /dev/null -w "%{http_code}"
test: curl --silent --fail http://fusionauth:9011/api/status -o /dev/null -w "%{http_code}"
interval: 5s
timeout: 5s
retries: 5
volumes:
- fusionauth_config:/usr/local/fusionauth/config
- fusionauth-config:/usr/local/fusionauth/config
- ./fusionauth/kickstart:/usr/local/fusionauth/kickstart
2 changes: 2 additions & 0 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ RUN yarn --frozen-lockfile
FROM base AS development
WORKDIR /code

RUN apt update && apt install -y wget && apt clean && rm -rf /var/lib/apt/lists/*

ENV NODE_ENV development

COPY . .
Expand Down