From 537b060968079227a896d2bd52aea6e0ebf988b1 Mon Sep 17 00:00:00 2001 From: RaviAnand Mohabir Date: Tue, 25 Mar 2025 18:14:37 +0100 Subject: [PATCH] ci: :construction_worker: add dockerfile and drone build pipeline --- .dockerignore | 2 ++ .drone.yml | 21 +++++++++++++++++++++ Dockerfile | 42 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 65 insertions(+) create mode 100644 .dockerignore create mode 100644 .drone.yml create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..f34875f --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +src/wasm_exec.js +public/main.wasm diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..56b3ab4 --- /dev/null +++ b/.drone.yml @@ -0,0 +1,21 @@ +kind: pipeline +type: kubernetes +name: publish Docker image on main +steps: + - image: plugins/docker + name: publish Docker image + settings: + auto_tag: true + cache_from: + - gitea.dikurium.ch/Freund_und_Partner/customer-files-organizer-web:latest + registry: gitea.dikurium.ch + repo: gitea.dikurium.ch/Freund_und_Partner/customer-files-organizer-web + username: + from_secret: git_user + password: + from_secret: git_pass +trigger: + branch: + - main + event: + - push diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..bcc8f4d --- /dev/null +++ b/Dockerfile @@ -0,0 +1,42 @@ +FROM golang:1.24-alpine AS wasm_builder + +WORKDIR /app + +COPY go.mod go.sum ./ +RUN go mod download + +COPY main.go ./ +RUN GOOS="js" GOARCH="wasm" go build -o main.wasm + +RUN cp "$(go env GOROOT)/lib/wasm/wasm_exec.js" ./ + +FROM node:22-alpine AS deps + +WORKDIR /app + +COPY package.json package-lock.json ./ +RUN npm ci + +FROM node:22-alpine AS builder + +WORKDIR /app + +COPY --from=wasm_builder /app/main.wasm ./public/main.wasm +COPY --from=wasm_builder /app/wasm_exec.js ./src/wasm_exec.js +COPY --from=deps /app/node_modules ./node_modules + +COPY . . + +RUN npm run build + +FROM node:22-alpine + +WORKDIR /app + +COPY --from=builder /app/dist ./dist + +RUN npm i -g serve + +EXPOSE 3000 + +CMD [ "serve", "-s", "dist" ]