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

Install python dev packages only for local development #1009

Closed
wants to merge 5 commits into from
Closed
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
4 changes: 3 additions & 1 deletion api/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ ENV PYTHONBUFFERED=1
# Activate the virtualenv
ENV PATH="/venv/bin:$PATH"

ARG PIPENV_INSTALL_ARGS

# - Install system packages needed for building Python dependencies
# - Create a virtualenv inside `/venv`
# - Install Pipenv to install Python dependencies
Expand All @@ -32,7 +34,7 @@ RUN apt-get update \
COPY Pipfile Pipfile.lock ./

# Install Python dependencies system-wide (uses the active virtualenv)
RUN pipenv install --system --deploy --dev
RUN pipenv install --system --deploy ${PIPENV_INSTALL_ARGS}

#######
# API #
Expand Down
1 change: 1 addition & 0 deletions api/justfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ wait-up: up
init: wait-up
cd .. && ./load_sample_data.sh

# Recreate volumes and containers specific to the API profile from scratch
recreate:
just ../down -v
just up "--force-recreate --build"
Expand Down
165 changes: 165 additions & 0 deletions docker-compose.override.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
###############
# Development #
###############

version: "2.4"
services:
db:
profiles:
- ingestion_server
- api
image: postgres:13.2-alpine
ports:
- "50254:5432"
volumes:
- api-postgres:/var/lib/postgresql/data
env_file:
- docker/db/env.docker
healthcheck:
test: "pg_isready -U deploy -d openledger"

upstream_db:
profiles:
- ingestion_server
- api
build: ./docker/upstream_db/
image: openverse-upstream_db
expose:
- "5432"
volumes:
- catalog-postgres:/var/lib/postgresql/data
- ./sample_data:/sample_data
env_file:
- docker/upstream_db/env.docker
healthcheck:
test: "pg_isready -U deploy -d openledger"

plausible_db:
profiles:
- frontend
image: postgres:13.2-alpine
expose:
- "5432"
volumes:
- plausible-postgres:/var/lib/postgresql/data
env_file:
- ./docker/plausible_db/env.docker
healthcheck:
test: "pg_isready -U deploy -d plausible"

plausible_ch:
profiles:
- frontend
image: clickhouse/clickhouse-server:22.6-alpine
volumes:
- plausible-clickhouse:/var/lib/clickhouse
- ./docker/clickhouse/clickhouse-config.xml:/etc/clickhouse-server/config.d/logging.xml:ro
- ./docker/clickhouse/clickhouse-user-config.xml:/etc/clickhouse-server/users.d/logging.xml:ro
ulimits:
nofile:
soft: 262144
hard: 262144

plausible:
profiles:
- frontend
image: plausible/analytics:latest
ports:
- "50288:8000"
command: sh -c "sleep 10 && /entrypoint.sh db createdb && /entrypoint.sh db migrate && /entrypoint.sh run"
depends_on:
- plausible_db
- plausible_ch
env_file:
- docker/plausible/env.docker

cache:
profiles:
- api
image: redis:4.0.10
ports:
- "50263:6379"

es:
profiles:
- ingestion_server
- api
image: docker.elastic.co/elasticsearch/elasticsearch:7.12.0
ports:
- "50292:9200"
env_file:
- docker/es/env.docker
healthcheck:
test:
[
"CMD-SHELL",
"curl -si -XGET 'localhost:9200/_cluster/health?pretty' | grep -qE 'yellow|green'",
]
interval: 10s
timeout: 60s
retries: 10
ulimits:
nofile:
soft: 65536
hard: 65536
# Memory limit for ES, as it tends to be a memory hoarder
# Set this value to an empty string to remove the limit
# https://docs.docker.com/compose/compose-file/compose-file-v2/#cpu-and-other-resources
mem_limit: ${ES_MEM_LIMIT:-4294967296} # 4 GiB in bytes
volumes:
- es-data:/usr/share/elasticsearch/data

web:
build:
context: ./api/
target: api
args:
SEMANTIC_VERSION: ${SEMANTIC_VERSION:-v1.0.0}
PIPENV_INSTALL_ARGS: "--dev"
depends_on:
- db
- es
- cache

ingestion_server:
build:
context: ./ingestion_server/
args:
PIPENV_INSTALL_ARGS: "--dev"
depends_on:
- db
- upstream_db
- es
- indexer_worker

indexer_worker:
build:
context: ./ingestion_server/
args:
PIPENV_INSTALL_ARGS: "--dev"
depends_on:
- db
- upstream_db
- es

proxy:
profiles:
- api
image: nginx:alpine
ports:
- "50200:9080"
- "50243:9443"
environment:
HTTPS_PORT: 50243 # See `ports` mapping above.
depends_on:
- web
volumes:
- ./docker/nginx/templates:/etc/nginx/templates
- ./docker/nginx/certs:/etc/nginx/certs

volumes:
api-postgres:
catalog-postgres:
plausible-postgres:
plausible-clickhouse:
es-data:
138 changes: 0 additions & 138 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,110 +1,5 @@
version: "2.4"
services:
db:
profiles:
- ingestion_server
- api
image: postgres:13.2-alpine
ports:
- "50254:5432"
volumes:
- api-postgres:/var/lib/postgresql/data
env_file:
- docker/db/env.docker
healthcheck:
test: "pg_isready -U deploy -d openledger"

upstream_db:
profiles:
- ingestion_server
- api
build: ./docker/upstream_db/
image: openverse-upstream_db
expose:
- "5432"
volumes:
- catalog-postgres:/var/lib/postgresql/data
- ./sample_data:/sample_data
env_file:
- docker/upstream_db/env.docker
healthcheck:
test: "pg_isready -U deploy -d openledger"

plausible_db:
profiles:
- frontend
image: postgres:13.2-alpine
expose:
- "5432"
volumes:
- plausible-postgres:/var/lib/postgresql/data
env_file:
- ./docker/plausible_db/env.docker
healthcheck:
test: "pg_isready -U deploy -d plausible"

plausible_ch:
profiles:
- frontend
image: clickhouse/clickhouse-server:22.6-alpine
volumes:
- plausible-clickhouse:/var/lib/clickhouse
- ./docker/clickhouse/clickhouse-config.xml:/etc/clickhouse-server/config.d/logging.xml:ro
- ./docker/clickhouse/clickhouse-user-config.xml:/etc/clickhouse-server/users.d/logging.xml:ro
ulimits:
nofile:
soft: 262144
hard: 262144

plausible:
profiles:
- frontend
image: plausible/analytics:latest
ports:
- "50288:8000"
command: sh -c "sleep 10 && /entrypoint.sh db createdb && /entrypoint.sh db migrate && /entrypoint.sh run"
depends_on:
- plausible_db
- plausible_ch
env_file:
- docker/plausible/env.docker

cache:
profiles:
- api
image: redis:4.0.10
ports:
- "50263:6379"

es:
profiles:
- ingestion_server
- api
image: docker.elastic.co/elasticsearch/elasticsearch:7.12.0
ports:
- "50292:9200"
env_file:
- docker/es/env.docker
healthcheck:
test:
[
"CMD-SHELL",
"curl -si -XGET 'localhost:9200/_cluster/health?pretty' | grep -qE 'yellow|green'",
]
interval: 10s
timeout: 60s
retries: 10
ulimits:
nofile:
soft: 65536
hard: 65536
# Memory limit for ES, as it tends to be a memory hoarder
# Set this value to an empty string to remove the limit
# https://docs.docker.com/compose/compose-file/compose-file-v2/#cpu-and-other-resources
mem_limit: ${ES_MEM_LIMIT:-4294967296} # 4 GiB in bytes
volumes:
- es-data:/usr/share/elasticsearch/data

web:
profiles:
- api
Expand All @@ -119,10 +14,6 @@ services:
ports:
- "50280:8000" # Django
- "50230:3000" # Sphinx (unused by default; see `sphinx-live` recipe)
depends_on:
- db
- es
- cache
env_file:
- api/env.docker
- api/.env
Expand All @@ -142,9 +33,6 @@ services:
ports:
- "50281:8001"
depends_on:
- db
- upstream_db
- es
- indexer_worker
volumes:
- ./ingestion_server:/ingestion_server
Expand All @@ -162,35 +50,9 @@ services:
command: gunicorn -c ./gunicorn_worker.conf.py
expose:
- "8002"
depends_on:
- db
- upstream_db
- es
volumes:
- ./ingestion_server:/ingestion_server
env_file:
- ingestion_server/env.docker
stdin_open: true
tty: true

proxy:
profiles:
- api
image: nginx:alpine
ports:
- "50200:9080"
- "50243:9443"
environment:
HTTPS_PORT: 50243 # See `ports` mapping above.
depends_on:
- web
volumes:
- ./docker/nginx/templates:/etc/nginx/templates
- ./docker/nginx/certs:/etc/nginx/certs

volumes:
api-postgres:
catalog-postgres:
plausible-postgres:
plausible-clickhouse:
es-data:
12 changes: 7 additions & 5 deletions ingestion_server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ ENV PYTHONBUFFERED=1
# Activate the virtualenv
ENV PATH="/venv/bin:$PATH"

ARG PIPENV_INSTALL_ARGS

# - Install system packages needed for building Python dependencies
# - Create a virtualenv inside `/venv`
# - Install Pipenv to install Python dependencies
Expand All @@ -21,7 +23,7 @@ RUN apt-get update \
COPY Pipfile Pipfile.lock ./

# Install Python dependencies system-wide (uses the active virtualenv)
RUN pipenv install --system --deploy --dev
RUN pipenv install --system --deploy ${PIPENV_INSTALL_ARGS}

####################
# Ingestion server #
Expand Down Expand Up @@ -53,12 +55,12 @@ RUN apt-get update \
&& mkdir /worker_state

# Create a non-root user
RUN useradd ingestionu
RUN chown ingestionu /worker_state
USER ingestionu
RUN useradd opener
RUN chown opener /worker_state
USER opener

# Copy code into the final image
COPY --chown=ingestionu . /ingestion_server/
COPY --chown=opener . /ingestion_server/

# Exposes
# - 8001: Gunicorn server for `ingestion_server` Falcon app
Expand Down
Loading