feat: add Dockerfile and GitLab CI/CD pipeline
Add Docker containerization with Deno and persistent SQLite volume. Add GitLab CI pipeline with build and deploy stages. Use SQLITE_PATH env var for configurable DB location.
This commit is contained in:
39
.gitlab-ci.yml
Normal file
39
.gitlab-ci.yml
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
stages:
|
||||||
|
- build
|
||||||
|
- deploy
|
||||||
|
|
||||||
|
variables:
|
||||||
|
IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA
|
||||||
|
IMAGE_LATEST: $CI_REGISTRY_IMAGE:latest
|
||||||
|
|
||||||
|
build:
|
||||||
|
stage: build
|
||||||
|
image: docker:latest
|
||||||
|
services:
|
||||||
|
- docker:dind
|
||||||
|
before_script:
|
||||||
|
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
|
||||||
|
script:
|
||||||
|
- docker build -t $IMAGE_TAG -t $IMAGE_LATEST .
|
||||||
|
- docker push $IMAGE_TAG
|
||||||
|
- docker push $IMAGE_LATEST
|
||||||
|
|
||||||
|
deploy:
|
||||||
|
stage: deploy
|
||||||
|
image: docker:latest
|
||||||
|
services:
|
||||||
|
- docker:dind
|
||||||
|
before_script:
|
||||||
|
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
|
||||||
|
script:
|
||||||
|
- docker pull $IMAGE_LATEST
|
||||||
|
- docker stop litenote-jetstream || true
|
||||||
|
- docker rm litenote-jetstream || true
|
||||||
|
- >
|
||||||
|
docker run -d
|
||||||
|
--name litenote-jetstream
|
||||||
|
--restart unless-stopped
|
||||||
|
-v litenote-data:/data
|
||||||
|
$IMAGE_LATEST
|
||||||
|
only:
|
||||||
|
- main
|
||||||
15
Dockerfile
Normal file
15
Dockerfile
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
FROM denoland/deno:2
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY deno.json deno.lock ./
|
||||||
|
RUN deno install
|
||||||
|
|
||||||
|
COPY . .
|
||||||
|
RUN deno cache main.ts
|
||||||
|
|
||||||
|
RUN mkdir -p /data
|
||||||
|
VOLUME /data
|
||||||
|
ENV SQLITE_PATH=/data/notes.db
|
||||||
|
|
||||||
|
CMD ["deno", "run", "--allow-net", "--allow-read", "--allow-write", "--allow-env", "main.ts"]
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
import { DB } from "https://deno.land/x/sqlite/mod.ts";
|
import { DB } from "https://deno.land/x/sqlite/mod.ts";
|
||||||
import type { Note } from "./note"
|
import type { Note } from "./note"
|
||||||
|
|
||||||
export const db = new DB("notes.db");
|
export const db = new DB(Deno.env.get("SQLITE_PATH") ?? "notes.db");
|
||||||
|
|
||||||
export const upsertNote = async (note: Note) => {
|
export const upsertNote = async (note: Note) => {
|
||||||
db.query(
|
db.query(
|
||||||
|
|||||||
Reference in New Issue
Block a user