Skip to content

Commit d6286c7

Browse files
committed
ci: lots of changes
1 parent a5ef0b1 commit d6286c7

47 files changed

Lines changed: 510 additions & 334 deletions

Some content is hidden

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

.env

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Default environment variable keys for runtime injection (env.sh).
2+
# Values are overridden at container startup by OpenShift configMap / env vars.
3+
# Per-app values are set in deployment configuration.
4+
5+
CMS_ORIGIN=
6+
FEDERATION_ROUTER_ENDPOINT=
7+
LINKEDEVENTS_EVENT_ENDPOINT=
8+
SKIP_BUILD_STATIC_GENERATION=1
9+
REVALIDATE_TOKEN=
10+
11+
NEXT_PUBLIC_APP_ORIGIN=http://localhost:3000
12+
NEXT_PUBLIC_IMAGE_PROXY_URL=https://images.weserv.nl/?w=1024&url=
13+
NEXT_PUBLIC_DEBUG=false
14+
NEXT_PUBLIC_DEFAULT_ISR_REVALIDATE_SECONDS=60
15+
NEXT_PUBLIC_ALLOW_UNAUTHORIZED_REQUESTS=false
16+
17+
NEXT_PUBLIC_SENTRY_PROJECT=
18+
NEXT_PUBLIC_SENTRY_DSN=
19+
NEXT_PUBLIC_SENTRY_ENVIRONMENT=
20+
NEXT_PUBLIC_SENTRY_RELEASE=
21+
NEXT_PUBLIC_SENTRY_TRACES_SAMPLE_RATE=0
22+
NEXT_PUBLIC_SENTRY_REPLAYS_SESSION_SAMPLE_RATE=0
23+
NEXT_PUBLIC_SENTRY_REPLAYS_ON_ERROR_SAMPLE_RATE=0
24+
NEXT_PUBLIC_SENTRY_TRACE_PROPAGATION_TARGETS=
25+
26+
NEXT_PUBLIC_CMS_HEADER_MENU_NAME_FI=
27+
NEXT_PUBLIC_CMS_HEADER_MENU_NAME_EN=
28+
NEXT_PUBLIC_CMS_HEADER_MENU_NAME_SV=
29+
NEXT_PUBLIC_CMS_HEADER_UNIVERSAL_BAR_MENU_NAME_FI=
30+
NEXT_PUBLIC_CMS_HEADER_UNIVERSAL_BAR_MENU_NAME_EN=
31+
NEXT_PUBLIC_CMS_HEADER_UNIVERSAL_BAR_MENU_NAME_SV=
32+
NEXT_PUBLIC_CMS_FOOTER_MENU_NAME_FI=
33+
NEXT_PUBLIC_CMS_FOOTER_MENU_NAME_EN=
34+
NEXT_PUBLIC_CMS_FOOTER_MENU_NAME_SV=
35+
NEXT_PUBLIC_CMS_ARTICLES_CONTEXT_PATH=/articles
36+
NEXT_PUBLIC_CMS_PAGES_CONTEXT_PATH=/pages
37+
38+
NEXT_PUBLIC_MATOMO_URL_BASE=
39+
NEXT_PUBLIC_MATOMO_SITE_ID=
40+
NEXT_PUBLIC_MATOMO_SRC_URL=
41+
NEXT_PUBLIC_MATOMO_TRACKER_URL=
42+
NEXT_PUBLIC_MATOMO_ENABLED=false
43+
44+
NEXT_PUBLIC_ASKEM_ENABLED=false
45+
NEXT_PUBLIC_ASKEM_API_KEY_FI=
46+
NEXT_PUBLIC_ASKEM_API_KEY_EN=
47+
NEXT_PUBLIC_ASKEM_API_KEY_SV=
48+
49+
NEXT_PUBLIC_SHOW_SIMILAR_EVENTS=true
50+
NEXT_PUBLIC_SHOW_SIMILAR_VENUES=true
51+
NEXT_PUBLIC_SHOW_TARGET_GROUP_FILTER=false
52+
NEXT_PUBLIC_SHOW_VENUES_UPCOMING_EVENTS=true
53+
NEXT_PUBLIC_SHOW_ENROLMENT_STATUS_IN_CARD_DETAILS=false
54+
55+
NEXT_PUBLIC_RELEASE=
56+
NEXT_PUBLIC_COMMITHASH=

Dockerfile

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,10 @@
99
###################################################################
1010
ARG BUILDER_FROM_IMAGE=helsinki.azurecr.io/ubi10/nodejs-24-pnpm-builder-base
1111

12-
FROM registry.access.redhat.com/ubi9/nodejs-24 AS deps
12+
FROM ${BUILDER_FROM_IMAGE} AS deps
1313

1414
USER root
1515

16-
RUN npm install -g pnpm@11.5.1
17-
1816
# install rsync (to fetch cached files)
1917
RUN yum update -y && \
2018
yum install -y rsync
@@ -158,12 +156,10 @@ CMD ["sh", "-c", "echo ${PROJECT}"]
158156
# last stage should be the production build." #
159157
###################################################################
160158

161-
FROM registry.access.redhat.com/ubi9/nodejs-24 AS develop
159+
FROM ${BUILDER_FROM_IMAGE} AS develop
162160

163161
USER root
164162

165-
RUN npm install -g pnpm@11.5.1
166-
167163
# Use non-root user
168164
USER default
169165

@@ -191,7 +187,7 @@ COPY --from=deps --chown=default:root /workspace-install ./
191187

192188
RUN pnpm install --frozen-lockfile
193189

194-
ENV PORT ${APP_PORT:-3000}
190+
ENV PORT ${APP_PORT:-8080}
195191

196192
# Expose port
197193
EXPOSE $PORT
@@ -207,7 +203,7 @@ CMD ["sh", "-c", "${DEV_START}"]
207203
# Stage 3: Extract a minimal image from the build #
208204
###################################################################
209205

210-
FROM registry.access.redhat.com/ubi9/nodejs-24 AS runner
206+
FROM ${BUILDER_FROM_IMAGE} AS runner
211207

212208
# Use non-root user
213209
USER default
@@ -247,9 +243,9 @@ RUN chgrp -R 0 /app/apps/${PROJECT}/.next/server/pages && chmod g+w -R /app/apps
247243
USER default
248244

249245
ENV NEXT_TELEMETRY_DISABLED 1
250-
ENV PORT ${APP_PORT:-3000}
246+
ENV PORT ${APP_PORT:-8080}
251247

252-
# Expose port
248+
# Expose port (OpenShift convention; mapped to host port 3000 in docker compose)
253249
EXPOSE $PORT
254250

255251
USER root
@@ -258,8 +254,11 @@ USER root
258254
RUN yum update -y && \
259255
yum install -y diffutils
260256

257+
COPY --chown=default:root .env /app/.env
258+
COPY --chown=default:root scripts/env.sh /app/scripts/env.sh
261259
COPY --chown=default:root run_node.sh /app/run_node.sh
262-
RUN chgrp 0 /app/run_node.sh && chmod +x /app/run_node.sh
260+
RUN chgrp 0 /app/run_node.sh /app/scripts/env.sh && \
261+
chmod +x /app/run_node.sh /app/scripts/env.sh
263262
USER default
264263

265264
# ENV PROD_START "./node_modules/.bin/next start apps/${PROJECT}/ -p ${PORT}"

DockerfileCache

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@
88
# ignore: all **/node_modules folders and .yarn/cache #
99
###################################################################
1010

11-
FROM registry.access.redhat.com/ubi9/nodejs-24 AS deps
11+
ARG BUILDER_FROM_IMAGE=helsinki.azurecr.io/ubi10/nodejs-24-pnpm-builder-base
12+
13+
FROM ${BUILDER_FROM_IMAGE} AS deps
1214

1315
USER root
14-
RUN npm install -g pnpm@11.5.1
1516

1617
# install rsync (to fetch cached files)
1718
RUN yum update -y && \
@@ -76,7 +77,7 @@ RUN yum remove -y rsync && \
7677
# This is used to speedup OpenShift builds #
7778
###################################################################
7879
# Build cache layer
79-
FROM registry.access.redhat.com/ubi9/nodejs-24 AS build_cache
80+
FROM ${BUILDER_FROM_IMAGE} AS build_cache
8081
# Build ARGS
8182
ARG PROJECT
8283
ARG CMS_ORIGIN
@@ -126,14 +127,11 @@ WORKDIR /app
126127
COPY --chown=default:root . .
127128
COPY --from=deps --chown=default:root /workspace-install ./
128129

129-
USER root
130-
RUN npm install -g pnpm@11.5.1
131-
132130
USER default
133131

134132
RUN pnpm install --frozen-lockfile
135133

136-
FROM registry.access.redhat.com/ubi9/nodejs-24 AS cache
134+
FROM ${BUILDER_FROM_IMAGE} AS cache
137135
ARG PROJECT
138136

139137
WORKDIR /app/
Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,22 @@
1+
import { getSentryRuntimeConfig } from '@events-helsinki/components/sentry/runtimeConfig';
12
import {
23
beforeSend,
34
beforeSendTransaction,
45
} from '@events-helsinki/components/sentry/utils';
56
import * as Sentry from '@sentry/nextjs';
67

7-
if (process.env.NEXT_PUBLIC_SENTRY_DSN) {
8+
const sentryConfig = getSentryRuntimeConfig();
9+
10+
if (sentryConfig.dsn) {
811
Sentry.init({
9-
dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,
10-
environment: process.env.NEXT_PUBLIC_SENTRY_ENVIRONMENT,
11-
release: process.env.NEXT_PUBLIC_SENTRY_RELEASE,
12-
// Adjust this value in production, or use tracesSampler for greater control
13-
// @see https://develop.sentry.dev/sdk/performance/
14-
// To turn it off, remove the line
15-
// @see https://github.com/getsentry/sentry-javascript/discussions/4503#discussioncomment-2143116
16-
tracesSampleRate: Number.parseFloat(
17-
process.env.NEXT_PUBLIC_SENTRY_TRACES_SAMPLE_RATE || '0'
18-
),
12+
dsn: sentryConfig.dsn,
13+
environment: sentryConfig.environment,
14+
release: sentryConfig.release,
15+
tracesSampleRate: sentryConfig.tracesSampleRate,
1916
normalizeDepth: 3,
2017
integrations: [Sentry.extraErrorDataIntegration({ depth: 3 })],
2118
beforeSend,
2219
beforeSendTransaction,
23-
// Setting this option to true will print useful information to the console while you're setting up Sentry.
2420
debug: false,
2521
});
2622
}
Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,22 @@
1+
import { getSentryRuntimeConfig } from '@events-helsinki/components/sentry/runtimeConfig';
12
import {
23
beforeSend,
34
beforeSendTransaction,
45
} from '@events-helsinki/components/sentry/utils';
56
import * as Sentry from '@sentry/nextjs';
67

7-
if (process.env.NEXT_PUBLIC_SENTRY_DSN) {
8+
const sentryConfig = getSentryRuntimeConfig();
9+
10+
if (sentryConfig.dsn) {
811
Sentry.init({
9-
dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,
10-
environment: process.env.NEXT_PUBLIC_SENTRY_ENVIRONMENT,
11-
release: process.env.NEXT_PUBLIC_SENTRY_RELEASE,
12-
// Adjust this value in production, or use tracesSampler for greater control
13-
// @see https://develop.sentry.dev/sdk/performance/
14-
// To turn it off, remove the line
15-
// @see https://github.com/getsentry/sentry-javascript/discussions/4503#discussioncomment-2143116
16-
tracesSampleRate: Number.parseFloat(
17-
process.env.NEXT_PUBLIC_SENTRY_TRACES_SAMPLE_RATE || '0'
18-
),
12+
dsn: sentryConfig.dsn,
13+
environment: sentryConfig.environment,
14+
release: sentryConfig.release,
15+
tracesSampleRate: sentryConfig.tracesSampleRate,
1916
normalizeDepth: 3,
2017
integrations: [Sentry.extraErrorDataIntegration({ depth: 3 })],
2118
beforeSend,
2219
beforeSendTransaction,
23-
// Setting this option to true will print useful information to the console while you're setting up Sentry.
2420
debug: false,
2521
});
2622
}

apps/events-helsinki/src/domain/app/AppConfig.ts

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {
22
getEnvOrError,
3+
getRuntimeEnv,
34
EventTypeId,
45
ignoredErrorCodesHeader,
56
} from '@events-helsinki/components';
@@ -24,7 +25,10 @@ class AppConfig {
2425
* inside the app.
2526
* */
2627
static get cmsOrigin() {
27-
return getEnvOrError(publicRuntimeConfig.cmsOrigin, 'CMS_ORIGIN');
28+
return getEnvOrError(
29+
getRuntimeEnv('CMS_ORIGIN') ?? publicRuntimeConfig.cmsOrigin,
30+
'CMS_ORIGIN'
31+
);
2832
}
2933

3034
/**
@@ -33,7 +37,8 @@ class AppConfig {
3337
* */
3438
static get federationGraphqlEndpoint() {
3539
return getEnvOrError(
36-
publicRuntimeConfig.federationRouter,
40+
getRuntimeEnv('FEDERATION_ROUTER_ENDPOINT') ??
41+
publicRuntimeConfig.federationRouter,
3742
'FEDERATION_ROUTER_ENDPOINT'
3843
);
3944
}
@@ -49,7 +54,8 @@ class AppConfig {
4954
* */
5055
static get linkedEventsEventEndpoint() {
5156
return getEnvOrError(
52-
publicRuntimeConfig.linkedEvents,
57+
getRuntimeEnv('LINKEDEVENTS_EVENT_ENDPOINT') ??
58+
publicRuntimeConfig.linkedEvents,
5359
'LINKEDEVENTS_EVENT_ENDPOINT'
5460
);
5561
}
@@ -60,7 +66,7 @@ class AppConfig {
6066
* */
6167
static get origin() {
6268
return getEnvOrError(
63-
process.env.NEXT_PUBLIC_APP_ORIGIN,
69+
getRuntimeEnv('NEXT_PUBLIC_APP_ORIGIN'),
6470
'NEXT_PUBLIC_APP_ORIGIN'
6571
);
6672
}
@@ -81,7 +87,9 @@ class AppConfig {
8187
* The application can then use a PostQuery to fetch the related information from an external service.
8288
*/
8389
static get cmsArticlesContextPath() {
84-
return process.env.NEXT_PUBLIC_CMS_ARTICLES_CONTEXT_PATH ?? '/articles';
90+
return (
91+
getRuntimeEnv('NEXT_PUBLIC_CMS_ARTICLES_CONTEXT_PATH') ?? '/articles'
92+
);
8593
}
8694

8795
/**
@@ -93,7 +101,7 @@ class AppConfig {
93101
* The application can then use a PageQuery to fetch the related information from an external service.
94102
*/
95103
static get cmsPagesContextPath() {
96-
return process.env.NEXT_PUBLIC_CMS_PAGES_CONTEXT_PATH ?? '/pages';
104+
return getRuntimeEnv('NEXT_PUBLIC_CMS_PAGES_CONTEXT_PATH') ?? '/pages';
97105
}
98106

99107
/** The supported LinkedEvent event types. */
@@ -131,13 +139,13 @@ class AppConfig {
131139
/** Should the application allow HTTP-connections? */
132140
static get allowUnauthorizedRequests() {
133141
return Boolean(
134-
parseEnvValue(process.env.NEXT_PUBLIC_ALLOW_UNAUTHORIZED_REQUESTS)
142+
parseEnvValue(getRuntimeEnv('NEXT_PUBLIC_ALLOW_UNAUTHORIZED_REQUESTS'))
135143
);
136144
}
137145

138146
/** A global debug switch for development purposes. */
139147
static get debug() {
140-
return Boolean(parseEnvValue(process.env.NEXT_PUBLIC_DEBUG));
148+
return Boolean(parseEnvValue(getRuntimeEnv('NEXT_PUBLIC_DEBUG')));
141149
}
142150

143151
/** A default HDS theme for the buttons. https://hds.hel.fi/foundation/design-tokens/colour. */
@@ -151,31 +159,31 @@ class AppConfig {
151159
> = ButtonVariant.Success;
152160

153161
static get matomoConfiguration() {
154-
const matomoUrlBase = process.env.NEXT_PUBLIC_MATOMO_URL_BASE;
155-
const matomoEnabled = process.env.NEXT_PUBLIC_MATOMO_ENABLED;
156-
const matomoSiteId = process.env.NEXT_PUBLIC_MATOMO_SITE_ID;
162+
const matomoUrlBase = getRuntimeEnv('NEXT_PUBLIC_MATOMO_URL_BASE');
163+
const matomoEnabled = getRuntimeEnv('NEXT_PUBLIC_MATOMO_ENABLED');
164+
const matomoSiteId = getRuntimeEnv('NEXT_PUBLIC_MATOMO_SITE_ID');
157165
const getMatomoUrlPath = (path: string) => `${matomoUrlBase}${path}`;
158166

159167
return {
160168
disabled: !parseEnvValue(matomoEnabled),
161169
urlBase: matomoUrlBase as string,
162170
srcUrl: getMatomoUrlPath(
163-
process.env.NEXT_PUBLIC_MATOMO_SRC_URL as string
171+
getRuntimeEnv('NEXT_PUBLIC_MATOMO_SRC_URL') as string
164172
),
165173
trackerUrl: getMatomoUrlPath(
166-
process.env.NEXT_PUBLIC_MATOMO_TRACKER_URL as string
174+
getRuntimeEnv('NEXT_PUBLIC_MATOMO_TRACKER_URL') as string
167175
),
168176
siteId: Number(matomoSiteId),
169177
};
170178
}
171179

172180
static askemFeedbackConfiguration(locale: 'en' | 'fi' | 'sv') {
173181
const askemApiKeyByLocale: Record<typeof locale, string | undefined> = {
174-
fi: process.env.NEXT_PUBLIC_ASKEM_API_KEY_FI,
175-
sv: process.env.NEXT_PUBLIC_ASKEM_API_KEY_SV,
176-
en: process.env.NEXT_PUBLIC_ASKEM_API_KEY_EN,
182+
fi: getRuntimeEnv('NEXT_PUBLIC_ASKEM_API_KEY_FI'),
183+
sv: getRuntimeEnv('NEXT_PUBLIC_ASKEM_API_KEY_SV'),
184+
en: getRuntimeEnv('NEXT_PUBLIC_ASKEM_API_KEY_EN'),
177185
};
178-
const askemEnabled = process.env.NEXT_PUBLIC_ASKEM_ENABLED;
186+
const askemEnabled = getRuntimeEnv('NEXT_PUBLIC_ASKEM_ENABLED');
179187
return {
180188
disabled: !parseEnvValue(askemEnabled),
181189
apiKey: askemApiKeyByLocale[locale] ?? '',
@@ -188,7 +196,9 @@ class AppConfig {
188196
* #on-demand-revalidation
189197
*/
190198
static get defaultRevalidate() {
191-
const envValue = process.env.NEXT_PUBLIC_DEFAULT_ISR_REVALIDATE_SECONDS;
199+
const envValue = getRuntimeEnv(
200+
'NEXT_PUBLIC_DEFAULT_ISR_REVALIDATE_SECONDS'
201+
);
192202
const value = envValue ? parseEnvValue(envValue) : 60;
193203

194204
if (typeof value !== 'number') {
@@ -224,22 +234,22 @@ class AppConfig {
224234
*/
225235
static get skipBuildStaticGeneration() {
226236
return Boolean(
227-
parseEnvValue(process.env.SKIP_BUILD_STATIC_GENERATION, false)
237+
parseEnvValue(getRuntimeEnv('SKIP_BUILD_STATIC_GENERATION'), false)
228238
);
229239
}
230240

231241
/** A feature flag for the similar events. */
232242
static get showSimilarEvents() {
233243
return Boolean(
234-
parseEnvValue(process.env.NEXT_PUBLIC_SHOW_SIMILAR_EVENTS, true)
244+
parseEnvValue(getRuntimeEnv('NEXT_PUBLIC_SHOW_SIMILAR_EVENTS'), true)
235245
);
236246
}
237247

238248
/** A feature flag that can be used to show the enrolment status in the card details. */
239249
static get showEnrolmentStatusInCardDetails() {
240250
return Boolean(
241251
parseEnvValue(
242-
process.env.NEXT_PUBLIC_SHOW_ENROLMENT_STATUS_IN_CARD_DETAILS,
252+
getRuntimeEnv('NEXT_PUBLIC_SHOW_ENROLMENT_STATUS_IN_CARD_DETAILS'),
243253
false
244254
)
245255
);

0 commit comments

Comments
 (0)