server: dockerfile updates and switch to bcryptjs

This commit is contained in:
Max Leiter 2022-03-28 19:26:16 -07:00
parent fd7d0be6ba
commit fb8f14fd98
WARNING! Although there is a key with this ID in the database it does not verify this commit! This commit is SUSPICIOUS.
GPG key ID: A3512F2F2F17EBDA
8 changed files with 58 additions and 30 deletions

View file

@ -1 +1,8 @@
node_modules/
Dockerfile
.dockerignore
node_modules
npm-debug.log
README.md
.next
.git
.env.*

View file

@ -20,6 +20,8 @@ COPY . .
# Learn more here: https://nextjs.org/telemetry
# Uncomment the following line in case you want to disable telemetry during the build.
ENV NEXT_TELEMETRY_DISABLED 1
ARG API_URL http://localhost:3000
ARG SECRET_KEY secret
RUN yarn build
@ -38,7 +40,7 @@ RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
# You only need to copy next.config.js if you are NOT using the default configuration
COPY --from=builder /app/next.config.js ./
COPY --from=builder /app/next.config.mjs ./
COPY --from=builder /app/public ./public
COPY --from=builder /app/package.json ./package.json

View file

@ -1,23 +1,50 @@
version: '3.8'
services:
server:
build: ./server
build:
context: ./server
args:
SECRET_KEY: secret
restart: unless-stopped
user: 1000:1000
environment:
- "JWT_SECRET=change_me!" # use `openssl rand -hex 32` to generate a strong secret
- "SECRET=secret"
- JWT_SECRET=change_me! # use `openssl rand -hex 32` to generate a strong secret
- SECRET_KEY=secret
expose:
- 3000
ports:
- "3000:3000"
networks:
- general
healthcheck:
test: [ "CMD", "curl", "-s", "localhost:3000"]
interval: 10s
timeout: 45s
retries: 10
container_name: server
client:
build: ./client
build:
context: ./client
network: host
args:
API_URL: http://localhost:3000
SECRET_KEY: secret
restart: unless-stopped
user: 1000:1000
environment:
- "API_URL=http://localhost:3000"
- "SECRET=secret"
- API_URL=http://localhost:3000
- SECRET_KEY=secret
ports:
- "3001:3001"
expose:
- 3001
networks:
- general
depends_on:
server:
condition: service_completed_successfully
condition: service_healthy
container_name: client
networks:
general:
driver: bridge

BIN
drift.sqlite Normal file

Binary file not shown.

View file

@ -16,6 +16,8 @@ WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
ENV NODE_ENV production
RUN apk add --no-cache git
ARG SECRET_KEY secret
RUN yarn build

View file

@ -15,7 +15,7 @@
"author": "",
"license": "ISC",
"dependencies": {
"bcrypt": "^5.0.1",
"bcryptjs": "^2.4.3",
"body-parser": "^1.18.2",
"celebrate": "^15.0.1",
"cors": "^2.8.5",
@ -37,7 +37,7 @@
"umzug": "^3.1.0"
},
"devDependencies": {
"@types/bcrypt": "^5.0.0",
"@types/bcryptjs": "^2.4.2",
"@types/cors": "^2.8.12",
"@types/express": "^4.0.39",
"@types/express-jwt": "^6.0.4",

View file

@ -1,5 +1,5 @@
import { Router } from "express"
import { genSalt, hash, compare } from "bcrypt"
import { genSalt, hash, compare } from "bcryptjs"
import { User } from "@lib/models/User"
import { sign } from "jsonwebtoken"
import config from "@lib/config"

View file

@ -147,12 +147,10 @@
resolved "https://registry.yarnpkg.com/@types/argparse/-/argparse-1.0.38.tgz#a81fd8606d481f873a3800c6ebae4f1d768a56a9"
integrity sha512-ebDJ9b0e702Yr7pWgB0jzm+CX4Srzz8RcXtLJDJB+BSccqMa36uyH/zUsSYao5+BD1ytv3k3rPYCq4mAE1hsXA==
"@types/bcrypt@^5.0.0":
version "5.0.0"
resolved "https://registry.yarnpkg.com/@types/bcrypt/-/bcrypt-5.0.0.tgz#a835afa2882d165aff5690893db314eaa98b9f20"
integrity sha512-agtcFKaruL8TmcvqbndlqHPSJgsolhf/qPWchFlgnW1gECTN/nKbFcoFnvKAQRFfKbh+BO6A3SWdJu9t+xF3Lw==
dependencies:
"@types/node" "*"
"@types/bcryptjs@^2.4.2":
version "2.4.2"
resolved "https://registry.yarnpkg.com/@types/bcryptjs/-/bcryptjs-2.4.2.tgz#e3530eac9dd136bfdfb0e43df2c4c5ce1f77dfae"
integrity sha512-LiMQ6EOPob/4yUL66SZzu6Yh77cbzJFYll+ZfaPiPPFswtIlA/Fs1MzdKYA7JApHU49zQTbJGX3PDmCpIdDBRQ==
"@types/body-parser@*":
version "1.19.2"
@ -490,13 +488,10 @@ bcrypt-pbkdf@^1.0.0:
dependencies:
tweetnacl "^0.14.3"
bcrypt@^5.0.1:
version "5.0.1"
resolved "https://registry.yarnpkg.com/bcrypt/-/bcrypt-5.0.1.tgz#f1a2c20f208e2ccdceea4433df0c8b2c54ecdf71"
integrity sha512-9BTgmrhZM2t1bNuDtrtIMVSmmxZBrJ71n8Wg+YgdjHuIWYF7SjjmCPZFB+/5i/o/PIeRpwVJR3P+NrpIItUjqw==
dependencies:
"@mapbox/node-pre-gyp" "^1.0.0"
node-addon-api "^3.1.0"
bcryptjs@^2.4.3:
version "2.4.3"
resolved "https://registry.yarnpkg.com/bcryptjs/-/bcryptjs-2.4.3.tgz#9ab5627b93e60621ff7cdac5da9733027df1d0cb"
integrity sha1-mrVie5PmBiH/fNrF2pczAn3x0Ms=
binary-extensions@^2.0.0:
version "2.2.0"
@ -2149,11 +2144,6 @@ next-tick@1, next-tick@^1.1.0:
resolved "https://registry.yarnpkg.com/next-tick/-/next-tick-1.1.0.tgz#1836ee30ad56d67ef281b22bd199f709449b35eb"
integrity sha512-CXdUiJembsNjuToQvxayPZF9Vqht7hewsvy2sOWafLvi2awflj9mOC6bHIg50orX8IJvWKY9wYQ/zB2kogPslQ==
node-addon-api@^3.1.0:
version "3.2.1"
resolved "https://registry.yarnpkg.com/node-addon-api/-/node-addon-api-3.2.1.tgz#81325e0a2117789c0128dab65e7e38f07ceba161"
integrity sha512-mmcei9JghVNDYydghQmeDX8KoAm0FAiYyIcUt/N4nhyAipB17pllZQDOJD2fotxABnt4Mdz+dKTO7eftLg4d0A==
node-addon-api@^4.2.0:
version "4.3.0"
resolved "https://registry.yarnpkg.com/node-addon-api/-/node-addon-api-4.3.0.tgz#52a1a0b475193e0928e98e0426a0d1254782b77f"