Skip to content

Commit 65b85f0

Browse files
authored
Merge pull request #13 from sanderegg/oetiker-build-update-2
fix simcore-sdk build
2 parents 6990abd + 280473a commit 65b85f0

File tree

42 files changed

+750
-465
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+750
-465
lines changed

.env-devel

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
HOST_GID=1000
2-
DOCKER_GID=1001
3-
RUN_DOCKER_ENGINE_ROOT=0
41
DOCKER_IMAGE_PREFIX=services_
52
DOCKER_IMAGE_TAG=latest
63

@@ -32,10 +29,10 @@ S3_SECRET_KEY=12345678
3229
S3_BUCKET_NAME=simcore
3330
S3_SECURE=0
3431

35-
SMTP_HOST=mail
32+
SMTP_HOST=mail.speag.com
3633
SMTP_PORT=25
3734

38-
VENV2=123
35+
VENV2=.venv27/
3936

4037
BF_API_KEY=none
4138
BF_API_SECRET=none

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ dist: xenial
22
env:
33
global:
44
- DOCKER_COMPOSE_VERSION=1.23.2
5-
- DOCKER_GID=1042
65
services:
76
- docker
87
addons:

Makefile

Lines changed: 28 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,40 @@
11
# author: Sylvain Anderegg
22

3-
# TODO: add flavours by combinging docker-compose files. Namely development, test and production.
43
VERSION := $(shell uname -a)
54

6-
# SAN this is a hack so that docker-compose works in the linux virtual environment under Windows
5+
# SAN: this is a hack so that docker-compose works in the linux virtual environment under Windows
76
WINDOWS_MODE=OFF
87
ifneq (,$(findstring Microsoft,$(VERSION)))
98
$(info detected WSL)
109
export DOCKER_COMPOSE=docker-compose
1110
export DOCKER=docker
12-
export RUN_DOCKER_ENGINE_ROOT=1
13-
# Windows does not have these things defined... but they are needed to execute a local swarm
14-
export DOCKER_GID=1042
15-
export HOST_GID=1000
11+
# SAN: Windows does not have these things defined... but they are needed to execute a local swarm
1612
WINDOWS_MODE=ON
1713
else ifeq ($(OS), Windows_NT)
1814
$(info detected Powershell/CMD)
1915
export DOCKER_COMPOSE=docker-compose.exe
2016
export DOCKER=docker.exe
21-
export RUN_DOCKER_ENGINE_ROOT=1
22-
export DOCKER_GID=1042
23-
export HOST_GID=1000
2417
WINDOWS_MODE=ON
2518
else ifneq (,$(findstring Darwin,$(VERSION)))
2619
$(info detected OSX)
2720
export DOCKER_COMPOSE=docker-compose
2821
export DOCKER=docker
29-
export RUN_DOCKER_ENGINE_ROOT=1
30-
export DOCKER_GID=1042
31-
export HOST_GID=1000
3222
else
3323
$(info detected native linux)
34-
# TODO: DO NOT TOUCH THIS CONFIG --- (ask mguidon)
3524
export DOCKER_COMPOSE=docker-compose
3625
export DOCKER=docker
37-
export RUN_DOCKER_ENGINE_ROOT=0
38-
export DOCKER_GID=1042
39-
export HOST_GID=1000
40-
# TODO: DO NOT TOUCH THIS CONFIG --- (ask mguidon)
41-
# FIXME: DOCKER_GID and HOST_GID should be removed when issue #90 is resolved
42-
# TODO: Add a meaningfull call to retrieve the local docker group ID and the user ID in linux.
4326
endif
4427

28+
export DOCKER_REGISTRY=masu.speag.com
29+
export SERVICES_VERSION=2.8.0
4530

46-
PY_FILES = $(strip $(shell find services packages -iname '*.py' -not -path "*egg*" -not -path "*contrib*" -not -path "*-sdk/python*" -not -path "*generated_code*" -not -path "*datcore.py" -not -path "*web/server*"))
47-
31+
PY_FILES := $(strip $(shell find services packages -iname '*.py' \
32+
-not -path "*egg*" \
33+
-not -path "*contrib*" \
34+
-not -path "*-sdk/python*" \
35+
-not -path "*generated_code*" \
36+
-not -path "*datcore.py" \
37+
-not -path "*web/server*"))
4838
TEMPCOMPOSE := $(shell mktemp)
4939

5040
SERVICES_LIST := apihub director sidecar storage webserver
@@ -55,23 +45,17 @@ VCS_URL:=$(shell git config --get remote.origin.url)
5545
VCS_REF:=$(shell git rev-parse --short HEAD)
5646
VCS_REF_CLIENT:=$(shell git log --pretty=tformat:"%h" -n1 services/web/client)
5747
VCS_STATUS_CLIENT:=$(if $(shell git status -s),'modified/untracked','clean')
58-
59-
BUILD_DATE:=$(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
60-
61-
PLATFORM_VERSION=3.38
62-
DOCKER_REGISTRY=masu.speag.com
63-
#DOCKER_REGISTRY=registry.osparc.io
64-
6548
export VCS_URL
6649
export VCS_REF
6750
export VCS_REF_CLIENT
6851
export VCS_STATUS_CLIENT
52+
53+
BUILD_DATE:=$(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
6954
export BUILD_DATE
70-
export SERVICES_VERSION=2.8.0
71-
export DOCKER_REGISTRY=masu.speag.com
7255

7356

74-
## Tools
57+
## Tools ------------------------------------------------------------------------------------------------------
58+
#
7559
tools =
7660

7761
ifeq ($(shell uname -s),Darwin)
@@ -87,7 +71,7 @@ endif
8771

8872
## ------------------------------------------------------------------------------------------------------
8973
.PHONY: all
90-
all: help
74+
all: help info
9175
ifdef tools
9276
$(error "Can't find tools:${tools}")
9377
endif
@@ -115,7 +99,8 @@ rebuild-devel: .env .tmp-webclient-build
11599

116100
.tmp-webclient-build:
117101
# TODO: fixes having services_webclient:build present for services_webserver:production when
118-
# targeting services_webserver:development
102+
# targeting services_webserver:development and ensures source-output folder at host
103+
mkdir -p services\web\client\source-output
119104
${DOCKER_COMPOSE} -f services/docker-compose.yml build webclient
120105

121106

@@ -256,11 +241,16 @@ create-staging-stack-file:
256241
.PHONY: info
257242
# target: info – Displays some parameters of makefile environments
258243
info:
259-
@echo '+ vcs ref '
260-
@echo ' - origin : ${VCS_URL}'
261-
@echo ' - all : ${VCS_REF}'
262-
@echo ' - web/client (${VCS_STATUS_CLIENT}): ${VCS_REF_CLIENT}'
263-
@echo '+ date : ${BUILD_DATE}'
244+
@echo '+ VCS_* '
245+
@echo ' - ULR : ${VCS_URL}'
246+
@echo ' - REF : ${VCS_REF}'
247+
@echo ' - (STATUS)REF_CLIENT : (${VCS_STATUS_CLIENT}) ${VCS_REF_CLIENT}'
248+
@echo '+ BUILD_DATE : ${BUILD_DATE}'
249+
@echo '+ VERSION : ${VERSION}'
250+
@echo '+ WINDOWS_MODE : ${WINDOWS_MODE}'
251+
@echo '+ DOCKER_REGISTRY : ${DOCKER_REGISTRY}'
252+
@echo '+ SERVICES_VERSION : ${SERVICES_VERSION}'
253+
@echo '+ PY_FILES : $(shell echo $(PY_FILES) | wc -w) files'
264254

265255

266256
.PHONY: pylint

ops/travis/unit-testing/simcore-sdk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ before_script() {
2828
if [ -n "$(bash ops/travis/helpers/test_for_changes $FOLDER_CHECKS)" ];
2929
then
3030
pip freeze
31+
make build
3132
docker images
3233
fi
3334
}

packages/simcore-sdk/tests/node_ports/docker-compose.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ services:
1818
- S3_SECRET_KEY=${S3_SECRET_KEY}
1919
- S3_BUCKET_NAME=${S3_BUCKET_NAME}
2020
- S3_SECURE=0
21-
- RUN_DOCKER_ENGINE_ROOT=1
2221
- BF_API_SECRET="none"
2322
- BF_API_KEY="none"
2423
restart: always

services/director/Dockerfile

Lines changed: 98 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,106 +1,141 @@
11
FROM python:3.6-alpine as base
2+
#
3+
# USAGE:
4+
# cd sercices/director
5+
# docker build -f Dockerfile -t director:prod --target production ../../
6+
# docker run director:prod
7+
#
8+
# REQUIRED: context expected at ``osparc-simcore/`` folder because we need access to osparc-simcore/packages
29

310
LABEL maintainer=sanderegg
411

5-
ARG DOCKER_GID_ARG=1001
12+
# simcore-user uid=8004(scu) gid=8004(scu) groups=8004(scu)
13+
RUN adduser -D -u 8004 -s /bin/sh -h /home/scu scu
614

715
RUN apk add --no-cache \
8-
su-exec
16+
su-exec
917

10-
# create user `scu` and `docker` group (with same id as in host)
11-
RUN adduser -D -u 8004 scu &&\
12-
addgroup -g $DOCKER_GID_ARG docker
18+
ENV PATH "/home/scu/.local/bin:$PATH"
1319

14-
ENV HOME /home/scu
15-
# TODO: tmp workaround for https://github.com/pypa/pip/issues/6197
16-
# - Added explicit --cache-dir that is removed at the end of the build
17-
ENV PIP /home/scu/.venv/bin/pip3 --cache-dir=/tmp/.pipcache
18-
# -----
20+
# All SC_ variables are customized
21+
ENV SC_PIP pip3 --no-cache-dir
22+
ENV SC_BUILD_TARGET base
1923

20-
EXPOSE 8001
24+
# TODO: update environs
2125
ENV REGISTRY_AUTH = ''
2226
ENV REGISTRY_USER = ''
2327
ENV REGISTRY_PW = ''
2428
ENV REGISTRY_URL = ''
2529
ENV PUBLISHED_HOST_NAME=''
2630
ENV EXTRA_HOSTS_SUFFIX = 'undefined'
2731

28-
# ----------------------------------------------------------------
29-
COPY --chown=scu:scu scripts/docker/healthcheck_curl_host.py /healthcheck/healthcheck_curl_host.py
30-
# will start to run after interval every interval. fails after timeout. fail do not count if during start-period. will do # retries
31-
HEALTHCHECK --interval=10s --timeout=30s --start-period=20s --retries=3 CMD [ "python3", "/healthcheck/healthcheck_curl_host.py", "http://localhost:8001/v0/" ]
3232

33-
WORKDIR /home/scu
33+
EXPOSE 8080
3434

3535
# -------------------------- Build stage -------------------
36+
# Installs build/package management tools and third party dependencies
3637
#
37-
# - Preserves relative folder structure
38+
# + /build WORKDIR
3839
#
39-
# + /home/scu/ $HOME
40-
# + services/director
41-
# ...
42-
# + packages
43-
# ...
40+
4441
FROM base as build
4542

43+
ENV SC_BUILD_TARGET build
44+
4645
RUN apk add --no-cache \
4746
gcc \
4847
libc-dev \
4948
git
5049

51-
# create virtual environment
52-
RUN python3 -m venv $HOME/.venv &&\
53-
$PIP install --upgrade \
50+
RUN $SC_PIP install --upgrade \
5451
pip \
5552
wheel \
5653
setuptools
5754

58-
# this is done to accelerate installation of director later on
59-
COPY --chown=scu:scu services/director/requirements/base.txt requirements-base.txt
60-
RUN $PIP install -r requirements-base.txt &&\
61-
rm requirements-base.txt
55+
WORKDIR /build
6256

63-
COPY --chown=scu:scu services/director/docker docker
57+
# install base 3rd party dependencies
58+
COPY services/director/requirements/*.txt \
59+
services/director/requirements/
6460

65-
# --------------------------Development stage -------------------
66-
FROM build as development
61+
RUN $SC_PIP install \
62+
-r services/director/requirements/base.txt
6763

68-
ARG HOST_GID_ARG=1000
64+
#--------------------------Cache stage -------------------
65+
# CI in master buils & pushes this target to speed-up image build
66+
#
67+
# + /build
68+
# + services/director [scu:scu] WORKDIR
69+
#
70+
FROM build as cache
6971

70-
# in dev-mode we give access to `scu` to host's mapped volumes
71-
# FIXME: files created by scu cannot be deleted by host! we need to do the same group in host?
72-
RUN addgroup -g $HOST_GID_ARG hgrp &&\
73-
addgroup scu hgrp && \
74-
chown -R scu:scu $HOME/.venv &&\
75-
rm -rf /tmp/.pipcache
72+
ENV SC_BUILD_TARGET cache
7673

77-
VOLUME /home/scu/services/director
78-
VOLUME /home/scu/packages/service-library
7974

80-
ENV DEBUG 1
81-
ENV RUN_DOCKER_ENGINE_ROOT=0
82-
ENTRYPOINT [ "/bin/sh", "docker/entrypoint.sh" ]
83-
CMD ["/bin/sh", "docker/boot.sh"]
75+
COPY --chown=scu:scu packages/service-library /build/packages/service-library
76+
COPY --chown=scu:scu services/director /build/services/director
8477

85-
# --------------------------Cache stage -------------------
86-
FROM build as cache
87-
COPY --chown=scu:scu services/director $HOME/services/director
88-
COPY --chown=scu:scu packages/service-library $HOME/packages/service-library
89-
WORKDIR $HOME/services/director
90-
RUN $PIP install -r requirements/prod.txt
91-
WORKDIR $HOME/packages/service-library
92-
# FIXME: is this really requirements/dev or rather requirements/prod.txt?
93-
RUN $PIP install -r requirements/dev.txt
78+
WORKDIR /build/services/director
79+
80+
81+
RUN $SC_PIP install -r requirements/prod.txt &&\
82+
$SC_PIP list -v
9483

9584

9685
# --------------------------Production stage -------------------
86+
# Final cleanup up to reduce image size and startup setup
87+
# Runs as scu (non-root user)
88+
#
89+
# + /home/scu $HOME = WORKDIR
90+
# + services/director [scu:scu]
91+
#
9792
FROM cache as production
98-
WORKDIR $HOME
99-
ENV DEBUG 0
100-
ENV RUN_DOCKER_ENGINE_ROOT=0
101-
RUN rm -rf $HOME/services &&\
102-
rm -rf $HOME/packages &&\
103-
rm -rf /tmp/.pipcache
104-
105-
ENTRYPOINT [ "/bin/sh", "docker/entrypoint.sh" ]
106-
CMD ["/bin/sh", "docker/boot.sh"]
93+
94+
95+
ENV SC_BUILD_TARGET production
96+
ENV SC_BOOT_MODE production
97+
98+
WORKDIR /home/scu
99+
100+
RUN mkdir -p services/director &&\
101+
chown scu:scu services/director &&\
102+
mv /build/services/director/docker services/director/docker &&\
103+
rm -rf /build
104+
105+
RUN apk del --no-cache\
106+
gcc \
107+
git
108+
109+
HEALTHCHECK --interval=30s \
110+
--timeout=120s \
111+
--start-period=30s \
112+
--retries=3 \
113+
CMD ["python3", "/home/scu/services/director/docker/healthcheck.py", "http://localhost:8080/v0/"]
114+
115+
ENTRYPOINT [ "/bin/sh", "services/director/docker/entrypoint.sh" ]
116+
CMD ["/bin/sh", "services/director/docker/boot.sh"]
117+
118+
119+
# --------------------------Development stage -------------------
120+
# Source code accessible in host but runs in container
121+
# Runs as myu with same gid/uid as host
122+
# Placed at the end to speed-up the build if images targeting production
123+
#
124+
# + /devel WORKDIR
125+
# + services (mounted volume)
126+
#
127+
FROM build as development
128+
129+
ENV SC_BUILD_TARGET development
130+
ENV SC_BOOT_MODE development
131+
132+
133+
# WORKDIR /build
134+
# NOTE: can copy from /build if necessary
135+
136+
WORKDIR /devel
137+
VOLUME /devel/packages
138+
VOLUME /devel/services/director/
139+
140+
ENTRYPOINT [ "/bin/sh", "services/director/docker/entrypoint.sh" ]
141+
CMD ["/bin/sh", "services/director/docker/boot.sh"]

services/director/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ Using the main Makefile of the oSparc platform allows for testing the director:
6666
make up-swarm-devel
6767
```
6868

69-
Then open [director-swagger-ui](http://localhost:8001/apidoc/) to see the director API and try out the different routes.
69+
Then open [director-swagger-ui](http://localhost:8080/apidoc/) to see the director API and try out the different routes.
7070

7171
## code generation from REST API "server side"
7272

0 commit comments

Comments
 (0)