This commit is contained in:
Rizky 2024-01-25 11:31:37 +07:00
parent 7aa0ab468e
commit 013ac47b4f
5 changed files with 27 additions and 16 deletions

3
.gitignore vendored
View File

@ -174,4 +174,5 @@ dist
# Finder (MacOS) folder config # Finder (MacOS) folder config
.DS_Store .DS_Store
app/* app/*
.data

View File

@ -4,13 +4,9 @@ WORKDIR /app/prasi
RUN apt-get update RUN apt-get update
RUN apt-get install unzip RUN apt-get install unzip
COPY pkgs/docker-prep.ts . COPY dockerzip .
RUN bun docker-prep.ts RUN unzip dockerzip
WORKDIR /app/prasi/_tmp_docker
RUN bun install RUN bun install
COPY _tmp_docker/node_modules .
WORKDIR /app/prasi
RUN rm -rf _tmp_docker
COPY . . COPY . .
EXPOSE 3000/tcp EXPOSE 3000/tcp

BIN
dockerzip Normal file

Binary file not shown.

View File

@ -1,5 +1,12 @@
import { $ } from "execa";
import fs from "fs"; import fs from "fs";
import { copyAsync, dirAsync, removeAsync } from "fs-jetpack"; import {
copyAsync,
dirAsync,
existsAsync,
removeAsync,
renameAsync,
} from "fs-jetpack";
import path from "path"; import path from "path";
const dir = { const dir = {
@ -30,13 +37,18 @@ const dir = {
}, },
}; };
await removeAsync(dir.path("_tmp_docker")); if (!(await existsAsync(dir.path("_tmp_docker")))) {
for (const file of Object.keys(dir.read(dir.path``))) { for (const file of Object.keys(dir.read(dir.path``))) {
if (file.endsWith("package.json")) { if (file.endsWith("package.json")) {
await dirAsync(dir.path("_tmp_docker", path.dirname(file))); await dirAsync(dir.path("_tmp_docker", path.dirname(file)));
await copyAsync(dir.path(file), dir.path("_tmp_docker", file), { await copyAsync(dir.path(file), dir.path("_tmp_docker", file), {
overwrite: true, overwrite: true,
}); });
}
} }
await copyAsync(dir.path("bun.lockb"), dir.path("_tmp_docker", "bun.lockb"));
await $({ cwd: dir.path("_tmp_docker") })`zip -r ../docker .`;
await $`mv docker.zip dockerzip`;
await removeAsync(dir.path("_tmp_docker"));
} }
await copyAsync(dir.path("bun.lockb"), dir.path("_tmp_docker", "bun.lockb"));

View File

@ -12,6 +12,8 @@ import { dirAsync, existsAsync } from "fs-jetpack";
import { dir } from "utils/dir"; import { dir } from "utils/dir";
import { $ } from "execa"; import { $ } from "execa";
import "./docker-prep";
g.mode = process.argv.includes("dev") ? "dev" : "prod"; g.mode = process.argv.includes("dev") ? "dev" : "prod";
g.datadir = g.mode === "prod" ? "../data" : ".data"; g.datadir = g.mode === "prod" ? "../data" : ".data";