Skip to content

[bugfix] ujson missing dependency in director service #1353

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

Merged
merged 8 commits into from
Mar 9, 2020
Merged
Show file tree
Hide file tree
Changes from 4 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
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,11 @@ $(CLIENT_WEB_OUTPUT):
-mkdir $(if $(IS_WIN),,-p) $(CLIENT_WEB_OUTPUT)


.PHONY: shell
shell:
docker run -it local/$(target):production /bin/sh


## docker SWARM -------------------------------
#
# - All resolved configuration are named as .stack-${name}-*.yml to distinguish from docker-compose files which can be parametrized
Expand Down
14 changes: 8 additions & 6 deletions services/director/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,21 @@ ENV SC_BUILD_TARGET build

# Installing client libraries and any other package you need
#
# - client library for PostgreSQL https://www.postgresql.org/docs/9.5/libpq.html
# libpq: client library for PostgreSQL https://www.postgresql.org/docs/9.5/libpq.html
# libstdc++: needed in ujson https://github.com/kohlschutter/junixsocket/issues/33
#
RUN apk update && \
apk add --no-cache \
libpq
libpq \
libstdc++




# Installing build dependencies (will be deleted in production)
RUN apk add --virtual .build-deps \
git \
gcc \
g++ \
libc-dev \
python-dev \
musl-dev \
Expand Down Expand Up @@ -150,9 +155,6 @@ FROM build as development
ENV SC_BUILD_TARGET development


# WORKDIR /build
# NOTE: can copy from /build if necessary

WORKDIR /devel
VOLUME /devel/packages
VOLUME /devel/services/director/
Expand Down
4 changes: 4 additions & 0 deletions services/director/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ build: openapi-specs ## builds docker image (using main services/docker-compose-
@$(MAKE) -C ${REPO_BASE_DIR} target=${APP_NAME} $@


.PHONY: shell
shell: ## runs shell in production container
@$(MAKE) --directory ${REPO_BASE_DIR} $@ target=${APP_NAME}

.PHONY: version-patch version-minor
version-patch version-minor: ## commits version as patch (bug fixes not affecting the API), minor/minor (backwards-compatible/INcompatible API addition or changes)
# upgrades as $(subst version-,,$@) version, commits and tags
Expand Down
32 changes: 32 additions & 0 deletions services/director/tests/test_ujson.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#
# Tests instalation issues related to ujson inside or outside the container
# https://github.com/kohlschutter/junixsocket/issues/33
#
import subprocess
import sys
import os
from pathlib import Path

current_dir = Path(sys.argv[0] if __name__ == "__main__" else __file__).resolve().parent


def test_ujson_installation():
# pylint: disable=c-extension-no-member
import ujson

assert ujson.__version__

with open(current_dir / "fixtures/dummy_service_description-v1.json") as fh:
obj = ujson.load(fh)
assert ujson.loads(ujson.dumps(obj)) == obj


def test_docker_installation():
registry = os.environ.get("DOCKER_REGISTRY", "local")
tag = os.environ.get("DOCKER_IMAGE_TAG", "production")

assert subprocess.run(
f'docker run -t --rm {registry}/director:{tag} python -c "import ujson; print(ujson.__version__)"',
shell=True,
check=True,
)