Skip to content

Commit

Permalink
feat: Convert to npm workspaces
Browse files Browse the repository at this point in the history
This simplifies dependency management because one `npm install` suffices.
  • Loading branch information
meyfa committed Dec 1, 2024
1 parent b6faf57 commit fe6a5c2
Show file tree
Hide file tree
Showing 14 changed files with 1,392 additions and 864 deletions.
File renamed without changes.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ jobs:
with:
node-version: 20
cache: npm
- run: npm ci && npm --prefix=client ci && npm --prefix=worker ci
- run: npm ci
- run: npm run lint
2 changes: 1 addition & 1 deletion .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- name: Build and push
uses: docker/build-push-action@v6
with:
context: ./client
context: ./
file: ./client/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Configure the following variables:
Then deploy the worker code:

```sh
npm --prefix=worker install && npm run deploy
npm install && npm run deploy
```

### Client
Expand Down Expand Up @@ -110,7 +110,7 @@ networks:
Install dependencies:
```sh
npm install && npm --prefix=worker install && npm --prefix=client install
npm install
```

Run linting:
Expand All @@ -122,13 +122,13 @@ npm run lint
Build the client without Docker:

```sh
npm --prefix=client run build
npm run build
```

Build the client Docker image:

```sh
docker build --tag=ddns-client ./client
docker build --tag=ddns-client --file=client/Dockerfile ./
```

Deploy the worker:
Expand Down
17 changes: 11 additions & 6 deletions client/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,24 @@
FROM node:20.18.1-alpine AS build
WORKDIR /app

COPY package*.json ./
COPY ./package*.json ./
COPY ./client/package*.json ./client/
RUN npm ci

COPY . .
COPY ./tsconfig.json ./
COPY ./client ./client
RUN npm run build

FROM node:20.18.1-alpine AS deploy
WORKDIR /app

COPY package*.json ./
RUN npm ci --omit=dev && apk add --no-cache tini
RUN apk add --no-cache tini

COPY --from=build /app/dist ./dist
COPY ./package*.json ./
COPY ./client/package*.json ./client/
RUN npm ci --omit=dev

COPY --from=build /app/client/dist ./client/dist

USER node

Expand All @@ -27,4 +32,4 @@ ENV DDNS_UPDATE_INTERVAL='300'
ENV DDNS_REQUEST_TIMEOUT='30'

ENTRYPOINT ["/sbin/tini", "--"]
CMD ["node", "--enable-source-maps", "dist/main.js"]
CMD ["node", "--enable-source-maps", "--disable-proto=delete", "client/dist/main.js"]
63 changes: 0 additions & 63 deletions client/package-lock.json

This file was deleted.

6 changes: 1 addition & 5 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@
"npm": ">=9"
},
"devDependencies": {
"@types/node": "20.17.9",
"typescript": "5.7.2"
},
"dependencies": {
"@meyfa/ddns": "file:.."
"@types/node": "20.17.9"
}
}
14 changes: 3 additions & 11 deletions client/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"lib": ["ES2022"],
"target": "ES2022",
"module": "NodeNext",
"moduleResolution": "nodenext",
"outDir": "./dist",
"verbatimModuleSyntax": true,
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"allowJs": true,
"declaration": false,
"sourceMap": true
"sourceMap": true,
"noEmit": false
},
"include": [
"src"
Expand Down
Loading

0 comments on commit fe6a5c2

Please sign in to comment.