Skip to content

Commit

Permalink
Merge pull request #33 from Jalle19/hidden-sensors
Browse files Browse the repository at this point in the history
Hidden sensors, logger, configurability, Docker
  • Loading branch information
Jalle19 authored Oct 26, 2023
2 parents a3cfecb + f728d12 commit 9cfbe21
Show file tree
Hide file tree
Showing 21 changed files with 469 additions and 54 deletions.
1 change: 1 addition & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@
"@typescript-eslint"
],
"rules": {
"no-console": "error"
}
}
7 changes: 7 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,10 @@ jobs:
run: npm ci
- name: Run eslint
run: npm run lint
build-docker:
name: Build Docker image
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build the image
run: docker build -t eachwatt/latest .
29 changes: 20 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,29 @@
FROM node:20-bookworm AS builder
FROM node:20-bookworm-slim AS builder

WORKDIR /app
COPY . /app

RUN npm install
# Copy all files needed to build the app
COPY package.json /app
COPY package-lock.json /app
COPY tsconfig.json /app
COPY src/ /app/src
COPY webif/ /app/webif

RUN npm run build
# Install dependencies and build the app and web interface
RUN npm install
RUN npm run build-all

FROM node:20-bookworm AS runtime
FROM node:20-bookworm-slim AS runtime

WORKDIR /app
COPY . /app
COPY --from=builder /app/dist/* /app

RUN npm install --omit=dev
# Copy everything needed to install dependencies
COPY package.json /app
COPY package-lock.json /app
RUN npm install --omit=dev --ignore-scripts

# Copy the built apps
COPY --from=builder /app/dist /app/dist
COPY --from=builder /app/webif/build /app/webif/build

ENTRYPOINT ["node", "dist/eachwatt.js"]
ENTRYPOINT ["node", "dist/eachwatt.js", "-c", "/data/config.yml"]
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,20 @@ To run the test suite, use:
```
npm run test
```

## Running with Docker

Build the Docker image:

```bash
docker build -t eachwatt/latest .
```

Run the container:

```bash
docker run --rm -v $(pwd):/data:ro -p 8080:8080 eachwatt/latest
```

The application expects the configuration file to be available as `/data/config.yml`, so in the above example,
`config.yml` should be present in the current directory.
4 changes: 4 additions & 0 deletions examples/config.sample.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
settings:
pollingInterval: 5000
httpPort: 8080

circuits:
# mains
- name: Main total
Expand Down
Loading

0 comments on commit 9cfbe21

Please sign in to comment.