feature: Adds migration Docker image.
This commit is contained in:
parent
217e73d9ec
commit
4a46b5aca0
5 changed files with 59 additions and 9 deletions
|
@ -35,6 +35,8 @@ jobs:
|
|||
- name: Build Docker images
|
||||
run: |
|
||||
docker build ./backend --tag git.terah.dev/imterah/hermes:$GITHUB_REF_NAME
|
||||
docker build -t git.terah.dev/imterah/hermes-backend-migration:$GITHUB_REF_NAME -f MigrationDockerfile .
|
||||
|
||||
docker build ./sshfrontend --tag git.terah.dev/imterah/hermes-lom:$GITHUB_REF_NAME
|
||||
|
||||
- name: Upload all Docker images
|
||||
|
@ -43,6 +45,10 @@ jobs:
|
|||
docker push git.terah.dev/imterah/hermes:$GITHUB_REF_NAME
|
||||
docker push git.terah.dev/imterah/hermes:latest
|
||||
|
||||
docker tag git.terah.dev/imterah/hermes-backend-migration:$GITHUB_REF_NAME git.terah.dev/imterah/hermes-backend-migration:latest
|
||||
docker push git.terah.dev/imterah/hermes-backend-migration:$GITHUB_REF_NAME
|
||||
docker push git.terah.dev/imterah/hermes-backend-migration:latest
|
||||
|
||||
docker tag git.terah.dev/imterah/hermes-lom:$GITHUB_REF_NAME git.terah.dev/imterah/hermes-lom:latest
|
||||
docker push git.terah.dev/imterah/hermes-lom:$GITHUB_REF_NAME
|
||||
docker push git.terah.dev/imterah/hermes-lom:latest
|
||||
|
|
23
MigrationDockerfile
Normal file
23
MigrationDockerfile
Normal file
|
@ -0,0 +1,23 @@
|
|||
FROM golang:latest AS build
|
||||
WORKDIR /build
|
||||
COPY backend /build
|
||||
RUN cd api; go build .
|
||||
FROM node:22.11.0-bookworm AS run
|
||||
LABEL org.opencontainers.image.source="https://git.terah.dev/imterah/nextnet"
|
||||
COPY migration-entrypoint.sh /app/entrypoint.sh
|
||||
COPY backend-legacy/src /app/legacy/src
|
||||
COPY backend-legacy/prisma /app/legacy/prisma
|
||||
COPY backend-legacy/tsconfig.json /app/legacy/
|
||||
COPY backend-legacy/package.json /app/legacy/
|
||||
COPY backend-legacy/package-lock.json /app/legacy/
|
||||
WORKDIR /app/legacy
|
||||
RUN npm install --save-dev
|
||||
RUN npm run build
|
||||
RUN rm out/**/*.ts out/**/*.map
|
||||
RUN rm -rf src
|
||||
RUN npm prune --production
|
||||
WORKDIR /app/modern
|
||||
COPY --from=build /build/api/api /app/modern/hermes
|
||||
RUN echo "{}" >> /app/modern/backends.json
|
||||
WORKDIR /app
|
||||
ENTRYPOINT sh entrypoint.sh
|
|
@ -7,11 +7,9 @@ COPY docker-entrypoint.sh /app/
|
|||
COPY tsconfig.json /app/
|
||||
COPY package.json /app/
|
||||
COPY package-lock.json /app/
|
||||
COPY srcpatch.sh /app/
|
||||
RUN sh srcpatch.sh
|
||||
RUN npm install --save-dev
|
||||
RUN npm run build
|
||||
RUN rm srcpatch.sh out/**/*.ts out/**/*.map
|
||||
RUN rm out/**/*.ts out/**/*.map
|
||||
RUN rm -rf src
|
||||
RUN npm prune --production
|
||||
ENTRYPOINT sh docker-entrypoint.sh
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
# !-- DO NOT USE THIS FOR DEVELOPMENT --!
|
||||
# This is only to source patch files in production deployments, if prisma isn't configured already.
|
||||
printf "//@ts-nocheck\n$(cat src/routes/backends/lookup.ts)" > src/routes/backends/lookup.ts
|
||||
printf "//@ts-nocheck\n$(cat src/routes/forward/lookup.ts)" > src/routes/forward/lookup.ts
|
||||
printf "//@ts-nocheck\n$(cat src/routes/user/lookup.ts)" > src/routes/user/lookup.ts
|
||||
printf "//@ts-nocheck\n$(cat src/routes/getPermissions.ts)" > src/routes/getPermissions.ts
|
29
migration-entrypoint.sh
Executable file
29
migration-entrypoint.sh
Executable file
|
@ -0,0 +1,29 @@
|
|||
#!/usr/bin/env bash
|
||||
echo "Welcome to the Hermes migration wizard."
|
||||
|
||||
if [ ! -f "/tmp/db.json.gz" ]; then
|
||||
echo "Exporting database contents..."
|
||||
cd /app/legacy
|
||||
node out/tools/exportDBContents.js /tmp/db.json.gz
|
||||
echo "!! IMPORTANT !!"
|
||||
echo "Database backup contents below:"
|
||||
echo "==== BEGIN BACKUP ===="
|
||||
cat /tmp/db.json.gz | base64
|
||||
echo "==== END BACKUP ===="
|
||||
echo "When copying, do NOT copy the BEGIN and END sections."
|
||||
fi
|
||||
|
||||
echo "Restoring backup..."
|
||||
|
||||
cd /app/modern
|
||||
./hermes -b ./backends.json import --bp /tmp/db.json.gz
|
||||
rm -rf /tmp/db.json.gz
|
||||
|
||||
echo "Restored backup. If this restore fails after the database has wiped, get a shell into the container,"
|
||||
echo "copy the backup contents into the container (base64 decoded) at '/tmp/db.json.gz',"
|
||||
echo "and rerun /app/entrypoint.sh."
|
||||
echo ""
|
||||
echo "If further issues continue, open an issue at 'https://git.terah.dev/imterah/hermes'."
|
||||
echo "If the migration succeeded, congratulations!"
|
||||
|
||||
sleep 10000
|
Loading…
Add table
Add a link
Reference in a new issue