Skip to content

Commit 1d685b5

Browse files
committed
Updated to latest xregexp
1 parent 4bcdbb0 commit 1d685b5

10 files changed

+123
-7094
lines changed

Dockerfile

+38-17
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,46 @@
1-
FROM node:14 as base
2-
RUN groupadd -r appuser && \
3-
useradd --create-home --gid appuser --home-dir /app --no-log-init --system appuser
1+
# syntax=docker/dockerfile:1.7-labs
2+
FROM node:22-bookworm AS base
43

5-
FROM base AS build
64
WORKDIR /app
7-
USER appuser
8-
COPY --chown=appuser:appuser . .
9-
RUN yarn install && \
10-
yarn run build
115

12-
FROM base AS run
6+
USER root
7+
8+
RUN apt-get update && \
9+
apt-get install -y dumb-init
10+
11+
COPY package.json package-lock.json /app/
12+
RUN npm install --audit=false --fund=false --omit dev
13+
14+
15+
#
16+
# build the app
17+
#
18+
FROM base AS builder
19+
20+
COPY . /app/
21+
22+
RUN npm install --audit=false --fund=false
23+
RUN npm run build
24+
25+
#
26+
# runner
27+
#
28+
FROM gcr.io/distroless/nodejs22-debian12:latest AS runner
29+
1330
ARG COMMIT="(not set)"
1431
ARG LASTMOD="(not set)"
1532
ENV COMMIT=$COMMIT
1633
ENV LASTMOD=$LASTMOD
17-
WORKDIR /app
18-
USER appuser
19-
COPY --chown=appuser:appuser . .
20-
#COPY --chown=appuser:appuser --from=build /app/dist /app/dist
21-
RUN yarn install --production
22-
EXPOSE 4000
23-
ENV PORT 4000
24-
CMD ["yarn", "run", "start"]
34+
ENV NODE_ENV=production
2535

36+
USER nonroot
37+
COPY --chown=nonroot:nonroot --from=base /usr/bin/dumb-init /usr/bin/dumb-init
38+
COPY --chown=nonroot:nonroot --from=base /app/node_modules /app/node_modules
39+
COPY --chown=nonroot:nonroot --from=builder /app/dist /app/dist
40+
COPY --chown=nonroot:nonroot --exclude=src . /app
41+
42+
WORKDIR /app
43+
ENV PORT 5000
44+
ENV HOSTNAME 0.0.0.0
45+
ENTRYPOINT ["/usr/bin/dumb-init", "--"]
46+
CMD ["/nodejs/bin/node", "dist/server.js"]

app.yaml

-10
This file was deleted.

docker-run.sh

+8-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,14 @@ set -o errexit
44
set -o pipefail
55
set -o nounset
66

7-
docker build -t regexplanet-xregexp .
7+
docker build \
8+
--build-arg COMMIT=$(git rev-parse --short HEAD) \
9+
--build-arg LASTMOD=$(date -u +%Y-%m-%dT%H:%M:%SZ) \
10+
--no-cache \
11+
--progress plain \
12+
--tag regexplanet-xregexp \
13+
.
14+
815
docker run \
916
-it \
1017
--publish 4000:4000 \

favicon.ico

9.05 KB
Binary file not shown.

package-lock.json

+54
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+3-4
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@
33
"version": "0.0.1",
44
"main": "server.js",
55
"scripts": {
6-
"build": "true",
6+
"build": "cp -pr src dist",
77
"start": "node server.js"
88
},
9-
"dependencies": {},
10-
"engines": {
11-
"node": "14"
9+
"dependencies": {
10+
"xregexp": "^5.1.1"
1211
},
1312
"repository": {
1413
"url": "https://www.github.com/fileformat/regexplanet-xregexp"

run.sh

+15-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,18 @@
22
#
33
# run the RegexPlanet XRegExp backend locally
44
#
5-
node server.js
5+
set -o errexit
6+
set -o pipefail
7+
set -o nounset
8+
9+
ENVFILE="./.env"
10+
11+
if [ -f "${ENVFILE}" ]
12+
then
13+
echo "INFO: load env file ${ENVFILE}"
14+
export $(grep "^[^#]" "${ENVFILE}")
15+
fi
16+
17+
npm install
18+
19+
node src/server.js

server.js renamed to src/server.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ var os = require("os");
44
var querystring = require('querystring');
55
var util = require("util");
66
var url = require("url");
7-
var XRegExp = require('./xregexp-all.js');
7+
var XRegExp = require('xregexp');
88

99
function h(unsafe)
1010
{
@@ -435,7 +435,7 @@ function serveTest(query, response)
435435
response.end();
436436
}
437437

438-
var port = Number(process.env.PORT || process.env.VCAP_APP_PORT || 8888);
438+
var port = Number(process.env.PORT || process.env.VCAP_APP_PORT || 4000);
439439

440440
http.createServer(function (request, response)
441441
{
@@ -470,7 +470,9 @@ http.createServer(function (request, response)
470470
}
471471
else if (parsedUrl.pathname == '/' || parsedUrl.pathname.lastIndexOf('/index.', 0) === 0 || parsedUrl.pathname.lastIndexOf('/default.', 0) === 0)
472472
{
473-
redirect(response, "http://www.regexplanet.com/advanced/xregexp/index.html");
473+
response.writeHead(404, { "Content-Type": "text/plain" });
474+
response.write(`Running XRegExp ${XRegExp.version}`);
475+
response.end();
474476
}
475477
else
476478
{

0 commit comments

Comments
 (0)