Skip to content

Commit b6a838b

Browse files
GitHKAndrei Neagu
andauthored
static-webserver is now used to serve static content (ITISFoundation#2342)
* first step: serving statics from a different server * disables setup_statics once more * fixed treafik rule * no static routes * first fully working refactor of with the static-webserver * refactoring and removing unused env vars * fixing tests after outsourcing to static-webserver * changed and split message on two lines * removed usage of dockerfile_environ * swarm deploy test fixes and additions * minor refactor * added readme * added missing service * regenerated spec * refactor * added static-webserver to the list of services to build * adding debug info in stdout * changed route name to fix issues with traefik rules * added to codeowners * making dockerfile more uniform with current patterns * fixing some very old habit * using better more proper names * removing unsued unv vars * adding more details * removed caching from this service * merged and moved settings * updated graph with services * reverting scope * process starts with pid = 1 * ensuring process is running under user * there are issues with the static-webserver running as non root * static-server upgrade enabling non root user moved default port to 8000 * updated static-webserver port * using the correct port * refactor and getting codeclimate unstuck * refactor and tring to make codeclimate work * triggering codeclimate Co-authored-by: Andrei Neagu <[email protected]>
1 parent fb04eda commit b6a838b

Some content is hidden

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

46 files changed

+323
-201
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ Makefile @pcrespov, @sanderegg
2828
/services/migration/ @pcrespov
2929
/services/sidecar/ @pcrespov, @mguidon
3030
/services/storage/ @mguidon, @pcrespov
31+
/services/static-webserver @GitHK
3132
/services/web/client/ @odeimaiz, @ignapas
3233
/services/web/server/ @pcrespov
3334
/tests/environment-setup/ @pcrespov
3435
/tests/performance/ @pcrespov
3536
/tests/public-api/ @pcrespov
36-
3737
requirements/* @pcrespov
3838
tools/* @pcrespov

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ SERVICES_LIST := \
3636
migration \
3737
sidecar \
3838
storage \
39-
webserver
39+
webserver \
40+
static-webserver
4041

4142
CLIENT_WEB_OUTPUT := $(CURDIR)/services/web/client/source-output
4243

25.6 KB
Loading

services/api-server/openapi.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1468,7 +1468,7 @@
14681468
"format": "uri"
14691469
}
14701470
},
1471-
"description": "A released solver with a specific version ",
1471+
"description": "A released solver with a specific version",
14721472
"example": {
14731473
"id": "simcore/services/comp/isolve",
14741474
"version": "2.1.1",

services/docker-compose-build.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,18 @@ services:
8787
org.label-schema.vcs-url: "${VCS_URL}"
8888
org.label-schema.vcs-ref: "${VCS_REF}"
8989

90+
static-webserver:
91+
image: local/static-webserver:${BUILD_TARGET:?build_target_required}
92+
build:
93+
context: ../
94+
dockerfile: services/static-webserver/Dockerfile
95+
target: ${BUILD_TARGET:?build_target_required}
96+
labels:
97+
org.label-schema.schema-version: "1.0"
98+
org.label-schema.build-date: "${BUILD_DATE}"
99+
org.label-schema.vcs-url: "${VCS_URL}"
100+
org.label-schema.vcs-ref: "${VCS_REF}"
101+
90102
webserver:
91103
image: local/webserver:${BUILD_TARGET:?build_target_required}
92104
build:

services/docker-compose.devel.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ services:
4343
- ./director-v2:/devel/services/director-v2
4444
- ../packages:/devel/packages
4545

46+
static-webserver:
47+
volumes:
48+
- ./web/client/source-output:/static-content
49+
environment:
50+
- SERVER_LOG_LEVEL=info
51+
4652
webserver:
4753
volumes:
4854
- ./web/server:/devel/services/web/server

services/docker-compose.yml

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,34 @@ services:
113113
- interactive_services_subnet
114114
- computational_services_subnet
115115

116+
static-webserver:
117+
image: ${DOCKER_REGISTRY:-itisfoundation}/static-webserver:${DOCKER_IMAGE_TAG:-latest}
118+
init: true
119+
environment:
120+
- SERVER_HOST=0.0.0.0
121+
- SERVER_PORT=8000
122+
- SERVER_LOG_LEVEL=error
123+
- SERVER_ROOT=/static-content
124+
deploy:
125+
placement:
126+
constraints:
127+
- node.platform.os == linux
128+
labels:
129+
- io.simcore.zone=${TRAEFIK_SIMCORE_ZONE}
130+
- traefik.http.middlewares.${SWARM_STACK_NAME}_gzip.compress=true
131+
- traefik.enable=true
132+
- traefik.http.services.${SWARM_STACK_NAME}_static_webserver.loadbalancer.server.port=8000
133+
- traefik.http.services.${SWARM_STACK_NAME}_static_webserver.loadbalancer.healthcheck.path=/
134+
- traefik.http.services.${SWARM_STACK_NAME}_static_webserver.loadbalancer.healthcheck.interval=2000ms
135+
- traefik.http.services.${SWARM_STACK_NAME}_static_webserver.loadbalancer.healthcheck.timeout=1000ms
136+
- traefik.http.middlewares.${SWARM_STACK_NAME}_static_webserver_retry.retry.attempts=2
137+
- traefik.http.routers.${SWARM_STACK_NAME}_static_webserver.rule=hostregexp(`{host:.+}`) && (PathPrefix(`/osparc`) || PathPrefix(`/s4l`) || PathPrefix(`/tis`) || PathPrefix(`/transpiled`) || PathPrefix(`/resource`))
138+
- traefik.http.routers.${SWARM_STACK_NAME}_static_webserver.entrypoints=http
139+
- traefik.http.routers.${SWARM_STACK_NAME}_static_webserver.priority=2
140+
- traefik.http.routers.${SWARM_STACK_NAME}_static_webserver.middlewares=${SWARM_STACK_NAME}_gzip@docker, ${SWARM_STACK_NAME}_static_webserver_retry
141+
networks:
142+
- default
143+
116144
webserver:
117145
image: ${DOCKER_REGISTRY:-itisfoundation}/webserver:${DOCKER_IMAGE_TAG:-latest}
118146
init: true
@@ -147,7 +175,7 @@ services:
147175
- traefik.http.services.${SWARM_STACK_NAME}_webserver.loadbalancer.healthcheck.interval=2000ms
148176
- traefik.http.services.${SWARM_STACK_NAME}_webserver.loadbalancer.healthcheck.timeout=1000ms
149177
- traefik.http.middlewares.${SWARM_STACK_NAME}_webserver_retry.retry.attempts=2
150-
- traefik.http.routers.${SWARM_STACK_NAME}_webserver.rule=hostregexp(`{host:.+}`)
178+
- traefik.http.routers.${SWARM_STACK_NAME}_webserver.rule=hostregexp(`{host:.+}`) && (PathPrefix(`/`) || PathPrefix(`/v0`) || PathPrefix(`/socket.io`) || PathPrefix(`/static-frontend-data.json`))
151179
- traefik.http.routers.${SWARM_STACK_NAME}_webserver.entrypoints=http
152180
- traefik.http.routers.${SWARM_STACK_NAME}_webserver.priority=1
153181
- traefik.http.routers.${SWARM_STACK_NAME}_webserver.middlewares=${SWARM_STACK_NAME}_gzip@docker, ${SWARM_STACK_NAME_NO_HYPHEN}_sslheader@docker, ${SWARM_STACK_NAME}_webserver_retry
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
FROM joseluisq/static-web-server:1.16.0-alpine as base
2+
3+
4+
5+
# simcore-user uid=8004(scu) gid=8004(scu) groups=8004(scu)
6+
ENV SC_USER_ID=8004 \
7+
SC_USER_NAME=scu \
8+
SC_BUILD_TARGET=base \
9+
SC_BOOT_MODE=default
10+
11+
RUN adduser -D -u ${SC_USER_ID} -s /bin/sh -h /home/${SC_USER_NAME} ${SC_USER_NAME}
12+
13+
# front-end client last (image name is the path to the Dockerfile)
14+
COPY --from=client/tools/qooxdoo-kit/builder:latest --chown=${SC_USER_NAME}:${SC_USER_NAME} \
15+
/project/build-output "/static-content"
16+
17+
# changing ownership of static-web-server files
18+
RUN chown -R ${SC_USER_NAME}:${SC_USER_NAME} /entrypoint.sh
19+
RUN chown -R ${SC_USER_NAME}:${SC_USER_NAME} /usr/local/bin/static-web-server
20+
RUN chown -R ${SC_USER_NAME}:${SC_USER_NAME} /public
21+
22+
USER ${SC_USER_NAME}
23+
24+
FROM base as build
25+
ENV SC_BUILD_TARGET build
26+
27+
FROM base as production
28+
ENV SC_BUILD_TARGET production
29+
30+
FROM base as development
31+
ENV SC_BUILD_TARGET development
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# static-webserver
2+
3+
Used for static content serving.
4+
5+
### Furtherr steps
6+
7+
In the future will fully serve all static content. Currently the `webserver` is still serving the following routes:
8+
9+
- `/` resolves to one of the three index.html pages inside the three products (osparc, tis, s4l)
10+
- `/static-frontend-data.json` contains information required by the fronted

services/web/Dockerfile

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@ ENV PYTHONDONTWRITEBYTECODE=1 \
4545
ENV PATH="${VIRTUAL_ENV}/bin:$PATH"
4646

4747

48-
# TODO: rename with common prefix!
49-
ENV SIMCORE_WEB_OUTDIR /home/scu/services/web/client
5048
# TODO: eliminate this variable!
5149
ENV IS_CONTAINER_CONTEXT Yes
5250

@@ -59,9 +57,6 @@ EXPOSE 8080
5957
#
6058
# + /build WORKDIR
6159
# + packages
62-
# + services/web/client $SIMCORE_WEB_OUTDIR
63-
# - index.html
64-
# ...
6560
# + services/web/server
6661
# + src
6762
# + tests
@@ -150,10 +145,6 @@ RUN apt-get update \
150145
COPY --chown=scu:scu services/web/server/docker services/web/server/docker
151146
RUN chmod +x services/web/server/docker/*.sh
152147

153-
# front-end client last (image name is the path to the Dockerfile)
154-
COPY --from=client/tools/qooxdoo-kit/builder:latest --chown=scu:scu \
155-
/project/build-output "${SIMCORE_WEB_OUTDIR}"
156-
157148
HEALTHCHECK --interval=30s \
158149
--timeout=120s \
159150
--start-period=30s \
@@ -177,8 +168,6 @@ FROM build as development
177168

178169
ENV SC_BUILD_TARGET development
179170

180-
ENV SIMCORE_WEB_OUTDIR /devel/services/web/client
181-
182171
WORKDIR /devel
183172

184173
RUN chown -R scu:scu "${VIRTUAL_ENV}"

0 commit comments

Comments
 (0)