diff --git a/Jenkinsfile b/Jenkinsfile index c28bf0d2fa1f10b024edee98db52ddecd73f2b6b..54f805cd546ed763bf0735c178d01e52fd613598 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -85,6 +85,23 @@ pipeline { // } } + stage('Build and push client container') { + steps { + script { + catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') { + dir('alfa-client') { + IMAGE_TAG = generateImageTag() + + sh 'npm run ci-build-alfa-client-container' + + sh "docker tag docker.ozg-sh.de/alfa-client:build-latest docker.ozg-sh.de/alfa-client:${IMAGE_TAG}" + sh "docker push docker.ozg-sh.de/alfa-client:${IMAGE_TAG}" + } + } + } + } + } + stage('Set Version') { when { not { diff --git a/alfa-client/apps/alfa/Caddyfile b/alfa-client/apps/alfa/Caddyfile new file mode 100644 index 0000000000000000000000000000000000000000..1b04b1fe065da8d164a3ec15220020e9f15a001f --- /dev/null +++ b/alfa-client/apps/alfa/Caddyfile @@ -0,0 +1,8 @@ +:8080 { + file_server + root * /usr/share/caddy +} + +:8081 { + respond "Hello, world! Test" +} diff --git a/alfa-client/apps/alfa/Dockerfile b/alfa-client/apps/alfa/Dockerfile index d69c70876f7ebb414614b0d47d7e5faeb2a44f6d..8ccc0f564746885f35f3286406323cb53fca81b2 100644 --- a/alfa-client/apps/alfa/Dockerfile +++ b/alfa-client/apps/alfa/Dockerfile @@ -1,24 +1,20 @@ -# Benutzt das vorher zu bauende Docker image "nx-build-base:x.y.z" -# Siehe ../Dockerfile.nx-build-base -FROM docker.ozg-sh.de/nx-build-base:2.0.0 AS builder +FROM caddy:2.6.4-alpine -ARG NODE_ENV -ARG CONFIGURATION +RUN adduser --system --ingroup root caddy -# Turn off Nx Daemon -ENV CI=true +WORKDIR /usr/share/caddy -WORKDIR /app/builder -COPY . . +COPY apps/alfa/Caddyfile /etc/caddy/Caddyfile -RUN echo "Building configuration: $CONFIGURATION..." +COPY dist/apps/alfa /usr/share/caddy -RUN npx nx build alfa --outputHashing=all --configuration ${CONFIGURATION:-development} \ - && ./node_modules/.bin/gzipper compress ./dist --verbose --exclude jpg,jpeg,png,ico,woff,woff2 +RUN chgrp -R 0 /usr/bin/caddy /etc/caddy /config/caddy /usr/share/caddy && \ + chmod -R g=u /usr/bin/caddy /etc/caddy /config/caddy /usr/share/caddy -FROM nginx:stable-alpine +USER caddy -WORKDIR /usr/share/nginx/html +EXPOSE 8080 8081 -COPY --from=builder /app/builder/dist/apps/alfa ./ -COPY --from=builder /app/builder/apps/alfa/nginx.conf /etc/nginx/nginx.conf +ENTRYPOINT ["/usr/bin/caddy"] + +CMD ["run", "--config", "/etc/caddy/Caddyfile", "--adapter", "caddyfile"] \ No newline at end of file diff --git a/alfa-client/apps/alfa/project.json b/alfa-client/apps/alfa/project.json index 539fb173beab9fa6efb50227f3efc49c7cc7bf37..932f9ed857394eebe857e588ed2cd2e7abea2ffb 100644 --- a/alfa-client/apps/alfa/project.json +++ b/alfa-client/apps/alfa/project.json @@ -122,6 +122,22 @@ "outputs": [ "{workspaceRoot}/coverage/apps/alfa" ] + }, + "container": { + "executor": "@nx-tools/nx-container:build", + "options": { + "engine": "docker", + "push": false, + "metadata": { + "images": [ + "docker.ozg-sh.de/alfa-client" + ], + "load": true, + "tags": [ + "build-latest" + ] + } + } } } } \ No newline at end of file diff --git a/alfa-client/package.json b/alfa-client/package.json index 8dc2364f58bb67444d25979f3fd75136efdac63e..6f0148b7f31491fecb49b5b507cf6fe7191ae40e 100644 --- a/alfa-client/package.json +++ b/alfa-client/package.json @@ -10,6 +10,7 @@ "start-for-screenreader": "nx run alfa:serve --host 192.168.178.20 --port 4300 --disable-host-check --verbose", "start:devbe": "nx run alfa:serve --port 4300 --disable-host-check --proxy-config proxy.dev.conf.json --verbose", "build": "nx run alfa:build", + "ci-build-alfa-client-container": "nx container alfa", "test": "nx affected --target=test --parallel 8 -- --runInBand", "test:cov": "jest --coverage", "test:lib": "nx test ${npm_config_lib} --watchAll",