Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

typescript. re-org src and dist. multi-step containerfile. ts-eslint #3

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions . eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
dist
**/*.js
src/**/*.js
*.js
3 changes: 2 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
*/*/node_modules
.git
.gitignore
.DS_Store
.DS_Store
dist
16 changes: 16 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
export default {
parser: "@typescript-eslint/parser",
parserOptions: {
ecmaVersion: "latest", // Allows the use of modern ECMAScript features
sourceType: "module", // Allows for the use of imports
},
extends: ["plugin:@typescript-eslint/recommended"], // Uses the linting rules from @typescript-eslint/eslint-plugin
env: {
node: true, // Enable Node.js global variables
},
rules: {
'no-console': 'off',
'import/prefer-default-export': 'off',
'@typescript-eslint/no-unused-vars': 'warn',
},
};
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
dist

# file io test files (should be deleted)
random_read_write.fio
fio.out

Expand Down
17 changes: 12 additions & 5 deletions Containerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# FROM node:latest as builder
# WORKDIR /app
# COPY . .
FROM node:latest as builder
WORKDIR /app
COPY . .
RUN npm install
RUN npm run build

############################

FROM ubuntu:latest

RUN apt-get -y update
Expand All @@ -14,8 +19,10 @@ apt-get install -y sysbench

RUN mkdir /test-volume
WORKDIR /workdir
COPY . .
RUN npm install
COPY --from=builder /app/dist .
COPY package.json .
COPY package-lock.json .
RUN npm install --omit=dev

# Swap entrypoint with this while developing js/index.js, docker run -it into the container,
# and modify js code
Expand Down
25 changes: 25 additions & 0 deletions DevContainerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# FROM node:latest as builder
# WORKDIR /app
# COPY . .
FROM ubuntu:latest

RUN apt-get -y update
RUN apt-get -y install git curl fio
RUN curl -fsSL https://deb.nodesource.com/setup_19.x | bash - &&\
apt-get install -y nodejs
RUN curl -s https://packagecloud.io/install/repositories/ookla/speedtest-cli/script.deb.sh | bash - &&\
apt-get install -y speedtest
RUN curl -s https://packagecloud.io/install/repositories/akopytov/sysbench/script.deb.sh | bash - &&\
apt-get install -y sysbench

RUN mkdir /test-volume
WORKDIR /workdir
COPY . .
RUN npm install

# Swap entrypoint with this while developing js/index.js, docker run -it into the container,
# and modify js code
CMD ["bash"]

# Entrypoint allows cli vars to pass to index.js
# ENTRYPOINT ["node", "index.js"]
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,9 @@ docker run ghcr.io/nicenode/benchbuddy --help
```
### Develop
Local environment setup:
1. In the Containerfile, swap commenting out the `entrypoint` with `cmd bash`
2. Build a local container `podman build -t benchbuddy-local .`
3. Run the container interactively with a volume mount from this repo to `/workdir` in the container `podman run -it -v $(pwd):/workdir benchbuddy-local` so that changes to code on your host machine will reflect inside the container.
4. Modify index.js code
5. Run `node /workdir/index.js` inside the container
1. Run `npm run work`. It will build a container locally and run it interactively with the speedometer repo code "mounted" in the container.
2. Now you can modify source code on your host machine as normal and it will change inside the container.
3. Run it with `npm run dev` inside the container to run your modified code.

## Why is my node not syncing?
The first goal of this project is to answer this question.
Expand Down
Loading