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

1
.gitignore vendored
View File

@ -175,3 +175,4 @@ dist
.DS_Store
app/*
.data

View File

@ -4,13 +4,9 @@ WORKDIR /app/prasi
RUN apt-get update
RUN apt-get install unzip
COPY pkgs/docker-prep.ts .
RUN bun docker-prep.ts
WORKDIR /app/prasi/_tmp_docker
COPY dockerzip .
RUN unzip dockerzip
RUN bun install
COPY _tmp_docker/node_modules .
WORKDIR /app/prasi
RUN rm -rf _tmp_docker
COPY . .
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 { copyAsync, dirAsync, removeAsync } from "fs-jetpack";
import {
copyAsync,
dirAsync,
existsAsync,
removeAsync,
renameAsync,
} from "fs-jetpack";
import path from "path";
const dir = {
@ -30,13 +37,18 @@ const dir = {
},
};
await removeAsync(dir.path("_tmp_docker"));
for (const file of Object.keys(dir.read(dir.path``))) {
if (file.endsWith("package.json")) {
await dirAsync(dir.path("_tmp_docker", path.dirname(file)));
await copyAsync(dir.path(file), dir.path("_tmp_docker", file), {
overwrite: true,
});
if (!(await existsAsync(dir.path("_tmp_docker")))) {
for (const file of Object.keys(dir.read(dir.path``))) {
if (file.endsWith("package.json")) {
await dirAsync(dir.path("_tmp_docker", path.dirname(file)));
await copyAsync(dir.path(file), dir.path("_tmp_docker", file), {
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 { $ } from "execa";
import "./docker-prep";
g.mode = process.argv.includes("dev") ? "dev" : "prod";
g.datadir = g.mode === "prod" ? "../data" : ".data";