Created
May 3, 2024 04:14
-
-
Save vinaysshenoy/137bcd253317d3fd76e12e13257cbf9c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
./gradlew shadowJar --no-daemon | |
jdkModules=$(jdeps --print-module-deps --ignore-missing-deps ./build/libs/db-migrations-1.0.0-flyway.jar) | |
echo "Building JRE with modules: $jdkModules" | |
rm -rf ./build/libs/jre | |
jlink --compress zip-6 --strip-debug --no-header-files --no-man-pages --output ./build/libs/jre --add-modules "$jdkModules" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ARG NODE_VERSION | |
# Typescript build | |
FROM node:$NODE_VERSION as builder | |
# Server build | |
WORKDIR /src | |
COPY ./src ./src | |
COPY index.ts ./ | |
COPY tracing.ts ./ | |
COPY tsconfig.json ./ | |
COPY tsconfig.build.json ./ | |
COPY package*.json ./ | |
RUN npm ci | |
RUN npm run buildServer | |
# DB Migrations build | |
RUN apt-get update | |
RUN apt-get install -y wget apt-transport-https gpg binutils | |
RUN wget -qO - https://packages.adoptium.net/artifactory/api/gpg/key/public | gpg --dearmor | tee /etc/apt/trusted.gpg.d/adoptium.gpg > /dev/null | |
RUN echo "deb https://packages.adoptium.net/artifactory/deb $(awk -F= '/^VERSION_CODENAME/{print$2}' /etc/os-release) main" | tee /etc/apt/sources.list.d/adoptium.list | |
RUN apt-get update | |
RUN apt-get install -y temurin-21-jdk | |
COPY ./db-migrations /db-migrations | |
RUN cd /db-migrations/ && ./build.sh | |
# Create server image | |
FROM node:$NODE_VERSION as server-base | |
COPY --from=builder /db-migrations/build/libs/ /flyway/bin/ | |
COPY ./flyway/sql /flyway/sql | |
WORKDIR /app | |
COPY --from=builder /src/package*.json ./ | |
COPY --from=builder /src/node_modules ./node_modules | |
COPY --from=builder /src/build ./ | |
COPY ./s3_asset_paths.json ./ | |
COPY ./src/resources/templates/ ./src/resources/templates/ | |
COPY ./server_start.sh ./ | |
RUN npm prune --production | |
EXPOSE ${SERVER_PORT} | |
ENV DOTENV_CONFIG_PATH=".env" | |
CMD [ "./server_start.sh" ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Only used for docker builds for deployment! | |
/flyway/bin/jre/bin/java -jar /flyway/bin/qweebi-db-migrations-1.0.0-flyway.jar -h="${POSTGRES_HOST}" -p="${POSTGRES_PORT}" -d="${POSTGRES_DB}" -u="${POSTGRES_USER}" -w="${POSTGRES_PASSWORD}" -m="/flyway/sql" | |
migrationStatus=$? | |
if [[ "$migrationStatus" -eq 0 ]]; then | |
node -r dotenv/config --import=./tracing.js ./index.js | |
else | |
exit $migrationStatus | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment