Skip to content

Commit

Permalink
Use console to build the node stage and make it available in CI (#34)
Browse files Browse the repository at this point in the history
CI with static mode needs an original node service for running tests.
`app` is the publishable nginx image so can't run the tests, so console
is needed for it.
  • Loading branch information
andytson-inviqa authored Jul 27, 2023
1 parent b21cfe9 commit 54a5db7
Show file tree
Hide file tree
Showing 12 changed files with 10 additions and 74 deletions.
2 changes: 1 addition & 1 deletion .ci/quality
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ run_shellcheck()

run_hadolint()
{
docker run --rm --volume "$(pwd):/app" hadolint/hadolint:latest-alpine /bin/sh -c "find '/app/$ANALYSE_PATH' -type f -name '*Dockerfile' ! -path '*/.git/*' ! -path '/app/tmp-test/*' ! -path '/app/test/*' ! -name '*.orig' -print -exec hadolint --ignore DL3003 --ignore DL3008 --ignore DL3016 --ignore DL3018 --ignore SC1091 --ignore DL3002 {} +"
docker run --rm --volume "$(pwd):/app" hadolint/hadolint:latest-alpine /bin/sh -c "find '/app/$ANALYSE_PATH' -type f -name '*Dockerfile' ! -path '*/.git/*' ! -path '/app/tmp-test/*' ! -path '/app/test/*' ! -name '*.orig' -print -exec hadolint --ignore DL3003 --ignore DL3006 --ignore DL3008 --ignore DL3016 --ignore DL3018 --ignore SC1091 --ignore DL3002 {} +"
}

run_shellcheck
Expand Down
2 changes: 1 addition & 1 deletion .ci/sample-dynamic/workspace.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
workspace('ci-node-spa-sample-dynamic'):
description: generated local workspace for ci-node-spa-sample.
harnessLayers:
- https://github.com/inviqa/harness-docker/archive/refs/tags/0.2.0-alpha2.tar.gz
- https://github.com/inviqa/harness-docker/archive/refs/tags/0.2.0-alpha3.tar.gz

attribute('app.build'): dynamic
2 changes: 1 addition & 1 deletion .ci/sample-static/workspace.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
workspace('ci-node-spa-sample-static'):
description: generated local workspace for ci-node-spa-sample.
harnessLayers:
- https://github.com/inviqa/harness-docker/archive/refs/tags/0.2.0-alpha2.tar.gz
- https://github.com/inviqa/harness-docker/archive/refs/tags/0.2.0-alpha3.tar.gz

attribute('app.build'): static
2 changes: 1 addition & 1 deletion _twig/docker-compose.yml/service/app.yml.twig
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ services:
stdin_open: true # react-scripts start terminates if stdin closed
volumes:
- {{ (syncvolume) ? @('workspace.name') ~ '-sync:/app:nocopy' : ('./:/app' ~ @('docker.compose.host_volume_options')) }}
- ./.my127ws/application:/home/node/application
- ./.my127ws/application:{{ @('app.code_owner_home') }}/application
- ./.my127ws/docker/image/app/root-node/usr/lib/task:/usr/lib/task
- ./.my127ws:/.my127ws
{% else %}
Expand Down
28 changes: 2 additions & 26 deletions docker/image/app/Dockerfile.twig
Original file line number Diff line number Diff line change
@@ -1,31 +1,8 @@
FROM {{ @('services.app.build.from.node') }} as node
ARG TARGETARCH
{% include 'docker/image/console/Dockerfile.twig' %}

FROM console as node
COPY .my127ws/docker/image/app/root-node /

WORKDIR /app

ENV APP_MODE={{ @('app.mode') }}

{% if @('app.build') == 'dynamic' %}
USER root

ADD https://github.com/krallin/tini/releases/download/v0.19.0/tini-${TARGETARCH} /sbin/docker-init
RUN chmod +x /sbin/docker-init

VOLUME /app

ENTRYPOINT ["/entrypoint.dynamic.sh"]
{% else %}
RUN chown node:node /app
COPY --chown=node:node ./ /app
USER node
RUN app build

ENTRYPOINT ["/entrypoint.sh"]

###

FROM {{ @('services.app.build.from.nginx') }} as nginx

RUN apk add --no-cache jq
Expand All @@ -36,4 +13,3 @@ COPY --from=node --chown=root:root {{ @('app.dist_path') }} /usr/share/nginx/htm

ENTRYPOINT [ "/docker-entrypoint.sh" ]
CMD ["nginx", "-g", "daemon off;"]
{% endif %}
21 changes: 0 additions & 21 deletions docker/image/app/root-node/usr/lib/task/build.sh.twig

This file was deleted.

4 changes: 2 additions & 2 deletions docker/image/app/root-node/usr/lib/task/start/dev.sh.twig
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

function task_start_dev()
{
{% for step in @('tasks.start_dev.steps') -%}
{% for step in @('task.start_dev.steps') -%}
{{ step|raw }}
{% endfor %}
}
}
16 changes: 0 additions & 16 deletions docker/image/console/root/usr/lib/task/build.sh.twig

This file was deleted.

2 changes: 1 addition & 1 deletion harness.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ harness('inviqa/node-spa'):
confd:
- harness:/
parentLayers:
- inviqa/docker:0.2.0-alpha1
- inviqa/docker:0.2.0-alpha3
---
attributes:
app:
Expand Down
3 changes: 1 addition & 2 deletions harness/attributes/common-spa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@ attributes.default:
web_directory: /usr/share/nginx/html
code_owner: node

tasks:
task:
build:
when: 'true'
steps:
- passthru yarn install
- "= @('app.build') == 'static' ? 'yarn build' : ''"
start_dev:
steps:
- passthru yarn install
- yarn dev

nginx:
Expand Down
1 change: 0 additions & 1 deletion harness/attributes/docker-spa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ attributes.default:
resources:
memory: 64Mi
console:
enabled: = @('app.build') == 'dynamic'
build:
from: = 'node:' ~ @('node.version') ~ '-slim'
publish: false
Expand Down
1 change: 0 additions & 1 deletion harness/config/confd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,4 @@ confd('harness:/'):
- { src: docker/image/app/Dockerfile }
- { src: docker/image/app/root-nginx/etc/nginx/conf.d/0-nginx.conf }
- { src: docker/image/app/root-nginx/etc/nginx/conf.d/default.conf }
- { src: docker/image/app/root-node/usr/lib/task/build.sh }
- { src: docker/image/app/root-node/usr/lib/task/start/dev.sh }

0 comments on commit 54a5db7

Please sign in to comment.