Skip to content

Commit

Permalink
Changes from go-web-app fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
thenav56 committed Nov 7, 2024
1 parent ba388d0 commit f07bdb7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ FROM nginx:1 AS nginx-serve
LABEL maintainer="IFRC"
LABEL org.opencontainers.image.source="github.com/IFRCGo/alert-hub-web-app"

COPY ./nginx-serve/apply-helm-config.sh /docker-entrypoint.d/
COPY ./nginx-serve/apply-config.sh /docker-entrypoint.d/
COPY ./nginx-serve/nginx.conf.template /etc/nginx/templates/default.conf.template
COPY --from=nginx-build /code/build /code/build

ENV SOURCE_DIRECTORY=/code/build/
ENV DESTINATION_DIRECTORY=/usr/share/nginx/html/
ENV OVERWRITE_DESTINATION=true
ENV APPLY_CONFIG__SOURCE_DIRECTORY=/code/build/
ENV APPLY_CONFIG__DESTINATION_DIRECTORY=/usr/share/nginx/html/
ENV APPLY_CONFIG__OVERWRITE_DESTINATION=true
4 changes: 3 additions & 1 deletion env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ import { defineConfig, Schema } from '@julr/vite-plugin-validate-env';
export default defineConfig({
APP_TITLE: Schema.string.optional(),
APP_ENVIRONMENT: (key, value) => {
// NOTE: APP_ENVIRONMENT_PLACEHOLDER is meant to be used with image builds
// The value will be later replaced with the actual value
const regex = /^production|staging|testing|alpha-\d+|development|APP_ENVIRONMENT_PLACEHOLDER$/;
const valid = !!value && (value.match(regex) !== null);
if (!valid) {
throw new Error(`Value for environment variable "${key}" must match regex "${regex}", instead received "${value}"`);
}
if (value === 'APP_ENVIRONMENT_PLACEHOLDER') {
console.warn(`Using ${value} for app environment. Make sure to not use this for builds without helm chart`)
console.warn(`Using ${value} for app environment. Make sure to not use this for builds without nginx-serve`)
}
return value as ('production' | 'staging' | 'testing' | `alpha-${number}` | 'development' | 'APP_ENVIRONMENT_PLACEHOLDER');
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/bin/bash -xe

SOURCE_DIRECTORY=${SOURCE_DIRECTORY?Required}
DESTINATION_DIRECTORY=${DESTINATION_DIRECTORY?Required}
SOURCE_DIRECTORY=${APPLY_CONFIG__SOURCE_DIRECTORY?Required}
DESTINATION_DIRECTORY=${APPLY_CONFIG__DESTINATION_DIRECTORY?Required}

# Parse arguments for --overwrite option
OVERWRITE_DESTINATION=${OVERWRITE_DESTINATION:-false}
OVERWRITE_DESTINATION=${APPLY_CONFIG__OVERWRITE_DESTINATION:-false}
for arg in "$@"; do
if [[ "$arg" == "--overwrite" ]]; then
OVERWRITE_DESTINATION=true
Expand Down

0 comments on commit f07bdb7

Please sign in to comment.