mirror of
https://github.com/Lumither/nocturne.git
synced 2026-10-17 10:26:21 +00:00
feat(migration) add migration
This commit is contained in:
9 files changed
+84
-22
No files matched your search
@@ -3,7 +3,21 @@ ifeq ($(ARCH), arm64)
|
||||
ARCH := aarch64
|
||||
endif
|
||||
|
||||
.PHONY: up
|
||||
clean:
|
||||
echo "todo"
|
||||
.PHONY: all
|
||||
all:up
|
||||
|
||||
.PHONY: build
|
||||
build:
|
||||
ARCH=$(ARCH) docker compose -f prod.compose.yaml build
|
||||
|
||||
.PHONY: up
|
||||
up:
|
||||
ARCH=$(ARCH) docker compose -f prod.compose.yaml up -d
|
||||
|
||||
.PHONY: down
|
||||
down:
|
||||
ARCH=$(ARCH) docker compose -f prod.compose.yaml down
|
||||
|
||||
.PHONY: rm
|
||||
rm:
|
||||
ARCH=$(ARCH) docker compose -f prod.compose.yaml rm
|
||||
+14
-13
@@ -1,16 +1,17 @@
|
||||
use chrono::Utc;
|
||||
use git2::Repository;
|
||||
// use chrono::Utc;
|
||||
// use git2::Repository;
|
||||
|
||||
fn main() {
|
||||
let repo = Repository::open("../..").expect("failed to open repository");
|
||||
let commit = repo
|
||||
.head()
|
||||
.expect("failed to get HEAD")
|
||||
.peel_to_commit()
|
||||
.expect("failed to get HEAD commit");
|
||||
let hash = commit.id().to_string();
|
||||
let utc_timestamp = Utc::now().date_naive().format("%Y%m%d").to_string();
|
||||
let pkg_version = env!("CARGO_PKG_VERSION");
|
||||
let build_id = format!("{}:{}@{}", pkg_version, &hash[..8], utc_timestamp);
|
||||
println!("cargo:rustc-env=BUILD_ID={}", build_id);
|
||||
// let repo = Repository::open("../..").expect("failed to open repository");
|
||||
// let commit = repo
|
||||
// .head()
|
||||
// .expect("failed to get HEAD")
|
||||
// .peel_to_commit()
|
||||
// .expect("failed to get HEAD commit");
|
||||
// let hash = commit.id().to_string();
|
||||
// let utc_timestamp = Utc::now().date_naive().format("%Y%m%d").to_string();
|
||||
// let pkg_version = env!("CARGO_PKG_VERSION");
|
||||
// let build_id = format!("{}:{}@{}", pkg_version, &hash[..8], utc_timestamp);
|
||||
// println!("cargo:rustc-env=BUILD_ID={}", build_id);
|
||||
println!("cargo:rustc-env=BUILD_ID=undefined");
|
||||
}
|
||||
@@ -5,6 +5,6 @@ RUN ["cargo", "build", "-r"]
|
||||
|
||||
FROM gcr.io/distroless/cc AS production
|
||||
ARG ARCH
|
||||
COPY --from=builder /app/target/release/api_server ./api_server
|
||||
COPY --from=builder /app/target/release/server ./server
|
||||
COPY --from=builder /usr/lib/${ARCH}-linux-gnu/libz.so.1 /usr/lib/${ARCH}-linux-gnu/
|
||||
ENTRYPOINT ["./api_server"]
|
||||
ENTRYPOINT ["./server"]
|
||||
@@ -0,0 +1,8 @@
|
||||
|
||||
.PHONY:all
|
||||
all: standalone
|
||||
|
||||
.PHONY: standalone
|
||||
standalone:
|
||||
npm run build
|
||||
cp -r public .next/standalone/ && cp -r .next/static .next/standalone/.next/
|
||||
@@ -8,7 +8,7 @@ const nextConfig = {
|
||||
},
|
||||
{
|
||||
protocol: 'https',
|
||||
hostname: 'pic.re'
|
||||
hostname: 'cdn.jsdelivr.net'
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export const SITE_CONFIG = {
|
||||
name: 'Atelier Lumiaethor',
|
||||
desc: ''
|
||||
desc: 'In pursuit of absolute simplicity and ultimate sophistication'
|
||||
};
|
||||
File renamed without changes.
@@ -0,0 +1,18 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
PGPASSFILE="/root/.pgpass"
|
||||
echo "postgres:5432:${POSTGRES_DB}:${POSTGRES_USER}:${POSTGRES_PASSWORD}" > "$PGPASSFILE"
|
||||
chmod 600 "$PGPASSFILE"
|
||||
|
||||
echo "waiting for postgres"
|
||||
until pg_isready -h postgres -U "$POSTGRES_USER" -d "$POSTGRES_DB"; do
|
||||
echo "retrying, sleep 2s"
|
||||
sleep 2
|
||||
done
|
||||
echo "db ready, running migrations"
|
||||
for file in /migrations/*.sql; do
|
||||
echo "applying $file"
|
||||
psql -h postgres -U "$POSTGRES_USER" -d "$POSTGRES_DB" -f "$file"
|
||||
done
|
||||
echo "migration complete"
|
||||
+23
-2
@@ -14,7 +14,7 @@ services:
|
||||
|
||||
backend:
|
||||
depends_on:
|
||||
- postgres
|
||||
- migrate
|
||||
build:
|
||||
context: ./backend
|
||||
dockerfile: ../container/release/backend.containerfile
|
||||
@@ -29,10 +29,31 @@ services:
|
||||
dns:
|
||||
- 1.1.1.1
|
||||
|
||||
|
||||
migrate:
|
||||
image: postgres:17
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
env_file:
|
||||
- ./.env
|
||||
- ./.env.local
|
||||
volumes:
|
||||
- ./migration/ddl:/migrations:ro
|
||||
- ./migration/migration.sh:/migration.sh:ro
|
||||
entrypoint: [ "/bin/sh", "/migration.sh" ]
|
||||
|
||||
|
||||
postgres:
|
||||
image: postgres:16.3
|
||||
image: postgres:17
|
||||
ports:
|
||||
- "5432:5432"
|
||||
env_file:
|
||||
- ./.env
|
||||
- ./.env.local
|
||||
healthcheck:
|
||||
test: [ "CMD-SHELL", "pg_isready -U $$POSTGRES_USER -d $$POSTGRES_DB" ]
|
||||
interval: 5s
|
||||
timeout: 3s
|
||||
retries: 10
|
||||
start_period: 5s
|
||||
Reference in new issue
Block a user