Skip to content

Commit cebb275

Browse files
committed
Merge branch 'develop'
2 parents fce6851 + cedc917 commit cebb275

File tree

7 files changed

+106
-21
lines changed

7 files changed

+106
-21
lines changed

.meta/300.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
## Add Docker support
2+
3+
By [@recurser](https://github.com/recurser)
4+
5+
Created 2022-04-09 01:35

Dockerfile

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
2+
# Install dependencies only when needed
3+
FROM node:17-alpine AS deps
4+
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
5+
RUN apk add --no-cache libc6-compat
6+
WORKDIR /app
7+
COPY package.json yarn.lock ./
8+
RUN yarn install --frozen-lockfile
9+
10+
# Rebuild the source code only when needed
11+
FROM node:17-alpine AS builder
12+
WORKDIR /app
13+
COPY --from=deps /app/node_modules ./node_modules
14+
COPY . .
15+
16+
ENV NEXT_TELEMETRY_DISABLED 1
17+
RUN yarn build
18+
19+
# Production image, copy all the files and run next
20+
FROM node:17-alpine AS runner
21+
WORKDIR /app
22+
23+
ENV NODE_ENV production
24+
ENV NEXT_TELEMETRY_DISABLED 1
25+
26+
RUN addgroup --system --gid 1001 nodejs
27+
RUN adduser --system --uid 1001 nextjs
28+
29+
# You only need to copy next.config.js if you are NOT using the default configuration
30+
COPY --from=builder /app/public ./public
31+
COPY --from=builder /app/package.json ./package.json
32+
33+
# Automatically leverage output traces to reduce image size
34+
# https://nextjs.org/docs/advanced-features/output-file-tracing
35+
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
36+
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
37+
38+
USER nextjs
39+
40+
EXPOSE 3000
41+
42+
ENV PORT 3000
43+
44+
CMD ["node", "server.js"]

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,26 @@ yarn all
4444
```
4545

4646

47+
## Running with Docker
48+
49+
Build the docker image (shortcut for `docker build -t string-is .`):
50+
51+
```bash
52+
yarn docker-build
53+
```
54+
55+
... and then run it (shortcut for `docker run -p 3000:3000 string-is`):
56+
57+
```bash
58+
yarn docker-run
59+
```
60+
61+
Alternatively you can build and run it with `docker-compose`:
62+
63+
```bash
64+
docker-compose up
65+
```
66+
4767
## Adding a new converter
4868

4969
The `src/lib` folder contains most of the conversion logic, and is pure TypeScript, with no React knowledge required.

docker-compose.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
version: '3.3'
3+
4+
services:
5+
string-is:
6+
build: .
7+
ports:
8+
- '3000:3000'
9+
image: string-is

next.config.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,11 @@ module.exports = nextTranslate({
9494
env: {
9595
CONTACT_EMAIL: 'hello@daveperrett.com',
9696
},
97+
// 'outputStandalone' is needed for docker support.
98+
// See https://github.com/vercel/next.js/tree/canary/examples/with-docker
99+
experimental: {
100+
outputStandalone: true,
101+
},
97102
headers,
98103
reactStrictMode: true,
99104
webpack: (config, { isServer, webpack }) => {

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
"all": "yarn eslint pages src --fix && yarn prettier && yarn jest && yarn build",
77
"build": "next build",
88
"dev": "next dev",
9+
"docker-build": "docker build -t string-is .",
10+
"docker-run": "docker run -p 3000:3000 string-is",
911
"eslint": "eslint --ext=js,ts,tsx",
1012
"format": "yarn eslint src pages --fix && yarn prettier",
1113
"jest": "TZ=UTC ./node_modules/.bin/jest",
@@ -30,7 +32,7 @@
3032
"jsonwebtoken": "^8.5.1",
3133
"lodash": "^4.17.21",
3234
"next": "12.1.4",
33-
"next-translate": "^1.3.5",
35+
"next-translate": "^1.4.0",
3436
"papaparse": "^5.3.2",
3537
"prettier": "^2.6.2",
3638
"prismjs": "^1.27.0",
@@ -77,7 +79,7 @@
7779
"eslint-import-resolver-typescript": "^2.7.1",
7880
"eslint-plugin-jsx-a11y": "^6.5.1",
7981
"eslint-plugin-react-hooks": "^4.4.0",
80-
"eslint-plugin-tsdoc": "^0.2.14",
82+
"eslint-plugin-tsdoc": "^0.2.15",
8183
"husky": "^7.0.4",
8284
"identity-obj-proxy": "^3.0.0",
8385
"jest": "^27.5.1",

yarn.lock

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -843,20 +843,20 @@
843843
"@jridgewell/resolve-uri" "^3.0.3"
844844
"@jridgewell/sourcemap-codec" "^1.4.10"
845845

846-
"@microsoft/tsdoc-config@0.15.2":
847-
version "0.15.2"
848-
resolved "https://registry.yarnpkg.com/@microsoft/tsdoc-config/-/tsdoc-config-0.15.2.tgz#eb353c93f3b62ab74bdc9ab6f4a82bcf80140f14"
849-
integrity sha512-mK19b2wJHSdNf8znXSMYVShAHktVr/ib0Ck2FA3lsVBSEhSI/TfXT7DJQkAYgcztTuwazGcg58ZjYdk0hTCVrA==
846+
"@microsoft/tsdoc-config@0.16.0":
847+
version "0.16.0"
848+
resolved "https://registry.yarnpkg.com/@microsoft/tsdoc-config/-/tsdoc-config-0.16.0.tgz#17226d12f77d2e394fb387439efd7ac6eaff1544"
849+
integrity sha512-Xvoh97qbYMsDK5TETcIu+uLeiwU5vtqXhyIkhCQ4GWooEt08qsXGu5F5SPdcwA0ox2EVukYnY5flF26wpFnMjw==
850850
dependencies:
851-
"@microsoft/tsdoc" "0.13.2"
851+
"@microsoft/tsdoc" "0.14.0"
852852
ajv "~6.12.6"
853853
jju "~1.4.0"
854854
resolve "~1.19.0"
855855

856-
"@microsoft/tsdoc@0.13.2":
857-
version "0.13.2"
858-
resolved "https://registry.yarnpkg.com/@microsoft/tsdoc/-/tsdoc-0.13.2.tgz#3b0efb6d3903bd49edb073696f60e90df08efb26"
859-
integrity sha512-WrHvO8PDL8wd8T2+zBGKrMwVL5IyzR3ryWUsl0PXgEV0QHup4mTLi0QcATefGI6Gx9Anu7vthPyyyLpY0EpiQg==
856+
"@microsoft/tsdoc@0.14.0":
857+
version "0.14.0"
858+
resolved "https://registry.yarnpkg.com/@microsoft/tsdoc/-/tsdoc-0.14.0.tgz#039bc2474a2cc226a995fd8f9536acbaaa775a96"
859+
integrity sha512-AXrYOAL5I2sZlYO/1JOGa5hCUemJ396OgMYR40t7gEjQtMJdJ28kbwJuQdRTKo/bmGFZuq4RsmG13I4L74xNbw==
860860

861861
"@next/env@12.1.4":
862862
version "12.1.4"
@@ -3390,13 +3390,13 @@ eslint-plugin-react@7.29.1:
33903390
semver "^6.3.0"
33913391
string.prototype.matchall "^4.0.6"
33923392

3393-
eslint-plugin-tsdoc@^0.2.14:
3394-
version "0.2.14"
3395-
resolved "https://registry.yarnpkg.com/eslint-plugin-tsdoc/-/eslint-plugin-tsdoc-0.2.14.tgz#e32e7c1df8af7b3009c252590bec07a1030afbf2"
3396-
integrity sha512-fJ3fnZRsdIoBZgzkQjv8vAj6NeeOoFkTfgosj6mKsFjX70QV256sA/wq+y/R2+OL4L8E79VVaVWrPeZnKNe8Ng==
3393+
eslint-plugin-tsdoc@^0.2.15:
3394+
version "0.2.15"
3395+
resolved "https://registry.yarnpkg.com/eslint-plugin-tsdoc/-/eslint-plugin-tsdoc-0.2.15.tgz#761a3f975d7466d58e8774c11eb83f2298248879"
3396+
integrity sha512-CVBX/uyfKTCD5Uho5tJGbrTfdNv+JxoCkz5tWsKp63pEEMWBIo9OGHcx0+kE8NJTv45Kx/zYl6AfbSOM9tp7DA==
33973397
dependencies:
3398-
"@microsoft/tsdoc" "0.13.2"
3399-
"@microsoft/tsdoc-config" "0.15.2"
3398+
"@microsoft/tsdoc" "0.14.0"
3399+
"@microsoft/tsdoc-config" "0.16.0"
34003400

34013401
eslint-scope@^5.1.1:
34023402
version "5.1.1"
@@ -5748,10 +5748,10 @@ nerf-dart@^1.0.0:
57485748
resolved "https://registry.yarnpkg.com/nerf-dart/-/nerf-dart-1.0.0.tgz#e6dab7febf5ad816ea81cf5c629c5a0ebde72c1a"
57495749
integrity sha1-5tq3/r9a2Bbqgc9cYpxaDr3nLBo=
57505750

5751-
next-translate@^1.3.5:
5752-
version "1.3.5"
5753-
resolved "https://registry.yarnpkg.com/next-translate/-/next-translate-1.3.5.tgz#06541951737028f1e78addce5ebec3b51a1460ba"
5754-
integrity sha512-JXNAuHsEjV/lGSghAQaYbKyxDr3ZQk1BiIKlGTKZg1qrxWjgxrj0sfmraQ6kRQORh7qC+OBQCVeiIkCCJfirxA==
5751+
next-translate@^1.4.0:
5752+
version "1.4.0"
5753+
resolved "https://registry.yarnpkg.com/next-translate/-/next-translate-1.4.0.tgz#8e423ea9010019ac9573cb6c88412273f8210f77"
5754+
integrity sha512-FWheoN83fWTTfZ2g+a77GBcXRDVfSDP45iA0+G5wRZYE3xPYMy/6X+1I5j+ouczoJ2JI54vH59W/veZ1tZDRGQ==
57555755

57565756
next@12.1.4:
57575757
version "12.1.4"

0 commit comments

Comments
 (0)