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

Dev environment + Typescript + Variables Improvements #5

Merged
merged 13 commits into from
Jul 3, 2023
Merged
Show file tree
Hide file tree
Changes from 8 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
18 changes: 18 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended"
],
"rules": {
"@typescript-eslint/no-unused-vars": [
"warn",
{
"argsIgnorePattern": "^_",
"varsIgnorePattern": "^_",
"caughtErrorsIgnorePattern": "^_"
}
]
},
"root": true
}
4 changes: 4 additions & 0 deletions .prettierrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# style settings, see https://prettier.io/docs/en/options.html
semi: false
singleQuote: true
trailingComma: es5
33 changes: 2 additions & 31 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,43 +1,14 @@

ARG NGINX_VERSION=1.24.0
ARG NJS_VERSION=0.7.12

FROM node:20.2.0-bullseye AS builder
ENV NODE_ENV=development
WORKDIR /app
COPY package.json package-lock.json* ./
RUN npm ci
COPY ./.mocharc.js ./
COPY ./babel.config.js ./
COPY ./rollup.config.js ./
COPY ./tsconfig.json ./
COPY ./src ./src

RUN npm run build

FROM nginx:${NGINX_VERSION}
ARG NGINX_VERSION
ARG NJS_VERSION
FROM nginx:1.24.0
ivanitskiy marked this conversation as resolved.
Show resolved Hide resolved

# following installation steps from http://nginx.org/en/linux_packages.html#Debian
RUN --mount=type=cache,target=/var/cache/apt <<EOF
set -eux
export DEBIAN_FRONTEND=noninteractive
apt-get -qq update
apt-get -qq install --yes --no-install-recommends --no-install-suggests \
curl gnupg2 ca-certificates debian-archive-keyring
curl gnupg2 ca-certificates debian-archive-keyring inotify-tools
update-ca-certificates
curl https://nginx.org/keys/nginx_signing.key | gpg --dearmor \
| tee /usr/share/keyrings/nginx-archive-keyring.gpg >/dev/null
gpg --dry-run --quiet --no-keyring --import --import-options import-show \
/usr/share/keyrings/nginx-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg] \
http://nginx.org/packages/mainline/debian $(echo $PKG_RELEASE | cut -f2 -d~) nginx" \
| tee /etc/apt/sources.list.d/nginx.list
apt-get -qq install --yes --no-install-recommends --no-install-suggests \
curl nginx-module-njs=${NGINX_VERSION}+${NJS_VERSION}-${PKG_RELEASE}
apt-get remove --purge --auto-remove --yes
rm -rf /var/lib/apt/lists/* /etc/apt/sources.list.d/nginx.list
ivanitskiy marked this conversation as resolved.
Show resolved Hide resolved
EOF
RUN mkdir -p /usr/lib/nginx/njs_modules
COPY --from=builder /app/dist/* /usr/lib/nginx/njs_modules/
21 changes: 17 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: '3'
services:
pebble:
image: letsencrypt/pebble:latest
platform: linux/amd64
command: pebble -config /etc/pebble/config.json
hostname: pebble
volumes:
Expand All @@ -12,18 +12,30 @@ services:
- 15000:15000 # HTTPS Management API
challtestsrv:
image: letsencrypt/pebble-challtestsrv:latest
platform: linux/amd64
command: pebble-challtestsrv -defaultIPv6 "" -defaultIPv4 10.30.50.3
hostname: challtestsrv
ports:
- 8055:8055 # HTTP Management API
node:
build:
context: .
dockerfile: Dockerfile.node
volumes:
- .:/app
- /app/node_modules
- node_dist:/app/dist
nginx:
image: nginxinc/njs-acme-experemental
image: nginxinc/njs-acme
build: .
command: nginx -c examples/nginx.conf
command: /nginx_wait_for_js nginx -c examples/nginx.conf
depends_on:
- node
hostname: proxy.nginx.com
volumes:
- ./examples:/etc/nginx/examples/
# - ./dist:/etc/nginx/dist/
- ./nginx_wait_for_js:/nginx_wait_for_js
- node_dist:/usr/lib/nginx/njs_modules/
- certs:/etc/letsencrypt/
environment:
- NJS_ACME_DIR=/etc/letsencrypt/
Expand All @@ -41,3 +53,4 @@ services:
start_period: 10s
volumes:
certs:
node_dist:
24 changes: 24 additions & 0 deletions nginx_wait_for_js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/sh
JS_FILE=/usr/lib/nginx/njs_modules/acme.js

# wait until the .js file appears
while ! [ -f $JS_FILE ]
do
echo "Waiting for $JS_FILE to appear..."
sleep 1
done

# start nginx in background
echo "Starting nginx..."
$@ &

sleep 3

echo "Watching for changes..."

# when the .js file is modified, reload nginx
inotifywait -m -e create,modify $JS_FILE |
while read filename
do
nginx -s reload
done
Loading