Skip to content

Commit

Permalink
Initial CI and frontend image
Browse files Browse the repository at this point in the history
  • Loading branch information
ilja-git committed Nov 13, 2023
1 parent be0fa95 commit df167d0
Show file tree
Hide file tree
Showing 8 changed files with 461 additions and 0 deletions.
75 changes: 75 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
version: 2
updates:
- package-ecosystem: npm
directory: "/frontend"
schedule:
interval: weekly
ignore:
- dependency-name: "*"
update-types: ["version-update:semver-patch"]
groups:
babel:
patterns:
- "@babel/*"
fontawesome:
patterns:
- "@fortawesome/*"
jest:
patterns:
- "@types/jest"
- "jest*"
- "ts-jest"
exclude-patterns:
- "jest-junit"
lint:
patterns:
- "@typescript-eslint/*"
- "eslint*"
- "prettier"
playwright:
patterns:
- "@playwright/*"
- "playwright"
react:
patterns:
- "react"
- "react-dom"
- "@types/react"
- "@types/react-dom"
sentry:
patterns:
- "@sentry/*"
typescript:
patterns:
- "tslib"
- "typescript"
- package-ecosystem: npm
directory: "/api-gateway"
schedule:
interval: weekly
ignore:
- dependency-name: "*"
update-types: ["version-update:semver-patch"]
groups:
jest:
patterns:
- "@types/jest"
- "jest*"
- "ts-jest"
exclude-patterns:
- "jest-junit"
lint:
patterns:
- "@typescript-eslint/*"
- "eslint*"
- "prettier"
node-saml:
patterns:
- "@node-saml/*"
- package-ecosystem: gradle
directory: "/service"
schedule:
interval: weekly
ignore:
- dependency-name: "*"
update-types: ["version-update:semver-patch"]
52 changes: 52 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Build
on:
- push

env:
AWS_REGION: eu-north-1
ECR_REGISTRY: 095341522062.dkr.ecr.eu-north-1.amazonaws.com
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions:
id-token: write
contents: read

jobs:
lint-shell:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: espoon-voltti/voltti-actions/shellcheck@v1

dockerize:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- name: oppivelvollisuus/frontend
path: frontend

steps:
- uses: actions/checkout@v3

- name: Build image
uses: espoon-voltti/voltti-actions/docker-build-push@master
id: build
with:
path: ${{ matrix.path }}
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
AWS_ROLE_TO_ASSUME: ${{ secrets.AWS_ROLE }}
AWS_REGION: ${{ env.AWS_REGION }}
registry: ${{ env.ECR_REGISTRY }}
name: ${{ matrix.name }}
build-args: |
build=${{ github.run_number }}
commit=${{ github.sha }}
outputs:
image: ${{ steps.build.outputs.image }}
image_name: ${{ steps.build.outputs.image_name }}
7 changes: 7 additions & 0 deletions frontend/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
*

!src
!nginx
!*.js
!*.json
!*.lock
48 changes: 48 additions & 0 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# syntax=docker/dockerfile:1.6.0
# SPDX-FileCopyrightText: 2017-2023 City of Espoo
#
# SPDX-License-Identifier: LGPL-2.1-or-later

ARG NGINX_VERSION=1.25.1

FROM node:20.9-bookworm-slim AS builder

WORKDIR /project

COPY ./package.json ./yarn.lock ./
RUN yarn install --immutable

COPY . .

RUN yarn build

FROM nginx:${NGINX_VERSION}

ENV NGINX_ENV=local \
TZ=UTC

RUN apt-get update \
&& apt-get -y dist-upgrade \
&& apt-get -y --no-install-recommends install ruby \
&& curl -sSfL https://github.com/espoon-voltti/s3-downloader/releases/download/v1.4.1/s3downloader-linux-amd64 \
-o /bin/s3download \
&& chmod +x /bin/s3download \
&& echo "520ea232e83a7cefe2a87d4f2af8433e383a4351464e213b7dd3b78ca0dc200f /bin/s3download" | sha256sum -c - \
&& rm -rf /var/lib/apt/lists/*


COPY ./nginx/bin/ /bin/
COPY ./nginx/etc/ /etc/

ENTRYPOINT ["/bin/proxy-entrypoint.sh"]
CMD ["nginx", "-g", "daemon off;"]

COPY --from=builder /project/dist/esbuild/oppivelvollisuus/ /static/

ARG build=none
ARG commit=none

ENV APP_BUILD="$build" \
APP_COMMIT="$commit"
LABEL fi.espoo.build="$build" \
fi.espoo.commit="$commit"
36 changes: 36 additions & 0 deletions frontend/nginx/bin/proxy-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/sh -eu

# SPDX-FileCopyrightText: 2017-2021 City of Espoo
#
# SPDX-License-Identifier: LGPL-2.1-or-later

# shellcheck disable=SC2155

set -eu

if [ "${DEBUG:-false}" = "true" ]; then
set -x
fi

export HOST_IP="UNAVAILABLE"

if [ "${SERVICE_URL:-X}" = 'X' ]; then
echo 'ERROR: SERVICE_URL must be a non-empty string!'
exit 1
fi

for template in /etc/nginx/conf.d/*.template /etc/nginx/*.template; do
if ! test -f "$template"; then
continue
fi
target=$(echo "$template" | sed -e "s/.template$//")

erb "$template" > "$target"
done

if [ "${DEBUG:-false}" = "true" ]; then
cat /etc/nginx/nginx.conf
cat /etc/nginx/conf.d/default.conf
fi

exec "$@"
Loading

0 comments on commit df167d0

Please sign in to comment.