Skip to content

Commit

Permalink
Merge pull request #57 from raydak-labs/ci/add-package-manager
Browse files Browse the repository at this point in the history
  • Loading branch information
BlackDark authored Aug 1, 2024
2 parents adbde22 + 1adf298 commit 8cae749
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 24 deletions.
8 changes: 5 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
# https://github.com/nodejs/docker-node/blob/main/docs/BestPractices.md
FROM node:20.16.0-slim AS base
FROM node:22.5.1-slim AS base
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"

RUN apt-get update && apt-get install -y \
git \
&& rm -rf /var/lib/apt/lists/* \
&& corepack enable && corepack prepare pnpm@9 --activate
&& corepack enable \
&& corepack prepare pnpm@9 --activate
WORKDIR /app
COPY package.json pnpm-lock.yaml /app/

FROM base AS prod-deps
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --prod --frozen-lockfile

FROM base
RUN corepack use pnpm@9
COPY --from=prod-deps /app/node_modules /app/node_modules
COPY index.ts /app/
COPY src/ /app/src/
COPY --from=prod-deps /app/node_modules /app/node_modules

ENV CONFIG_LOCATION=/app/config/config.yml
ENV SECRETS_LOCATION=/app/config/secrets.yml
Expand Down
1 change: 1 addition & 0 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ const run = async () => {
if (IS_DRY_RUN) {
logger.info("DryRun: Running in dry-run mode!");
}

const applicationConfig = getConfig();

await cloneRecyclarrTemplateRepo();
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
},
"devDependencies": {
"@playwright/test": "1.45.3",
"@types/node": "20.14.13",
"@types/node": "22.0.2",
"@vitest/coverage-v8": "2.0.5",
"prettier": "3.3.3",
"typescript": "5.5.4",
Expand Down
50 changes: 31 additions & 19 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 12 additions & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { readFileSync } from "fs";
import { existsSync, readFileSync } from "fs";
import yaml from "yaml";
import { logger } from "./logger";
import { YamlConfig } from "./types";
import { ROOT_PATH } from "./util";

Expand All @@ -24,6 +25,11 @@ export const getConfig = (): YamlConfig => {
return config;
}

if (!existsSync(CONFIG_LOCATION)) {
logger.error(`Config file in location "${CONFIG_LOCATION}" does not exists.`);
throw new Error("Config file not found.");
}

const file = readFileSync(CONFIG_LOCATION, "utf8");
config = yaml.parse(file, { customTags: [secretsTag] }) as YamlConfig;
return config;
Expand All @@ -34,6 +40,11 @@ export const getSecrets = () => {
return secrets;
}

if (!existsSync(SECRETS_LOCATION)) {
logger.error(`Secret file in location "${SECRETS_LOCATION}" does not exists.`);
throw new Error("Secret file not found.");
}

const file = readFileSync(SECRETS_LOCATION, "utf8");
config = yaml.parse(file);
return config;
Expand Down

0 comments on commit 8cae749

Please sign in to comment.