Skip to content

Commit

Permalink
feat: Setup docker
Browse files Browse the repository at this point in the history
  • Loading branch information
PleBea committed Jan 12, 2024
1 parent 24d271a commit e36af20
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 6 deletions.
28 changes: 28 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
FROM node:18.19-alpine AS builder
ENV NODE_ENV production

RUN apk add --no-cache tzdata && \
echo 'Etc/UTC' > /etc/timezone

WORKDIR /usr/src/app

COPY . .

RUN yarn install

RUN yarn build

FROM node:18.19-alpine

WORKDIR /app

COPY --from=builder /usr/src/app/dist /app/dist
COPY --from=builder /usr/src/app/.pnp.cjs /app/.pnp.cjs
COPY --from=builder /usr/src/app/.yarnrc.yml /app/.yarnrc.yml
COPY --from=builder /usr/src/app/.yarn /app/.yarn
COPY --from=builder /usr/src/app/package.json /app/package.json
COPY --from=builder /usr/src/app/yarn.lock /app/yarn.lock

EXPOSE 3000
ENV NODE_ENV production
CMD [ "yarn", "start:prod" ]
28 changes: 28 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
version: '3'

services:
web:
build: .
restart: always
ports:
- '3002:3000'
env_file:
- ./src/env/production.env
depends_on:
- db
db:
image: mysql:8.0.3
platform: linux/x86_64
restart: always
ports:
- '3306:3306'
environment:
MYSQL_ROOT_PASSWORD: WFxKSZbug42Eaw4TFk
MYSQL_DATABASE: logcon
MYSQL_USER: logcon
MYSQL_PASSWORD: 8V4WzkXXxtVhTYYyUJ
TZ: Asia/Seoul
volumes:
- ./db/mysql/data:/var/lib/mysql
- ./db/mysql/config:/etc/mysql/conf.d
- ./db/mysql/init:/docker-entrypoint-initdb.d
10 changes: 4 additions & 6 deletions src/validators/auth.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { readFileSync } from 'fs';

const validateEmail = (email: string) => {
const re =
/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
Expand All @@ -8,10 +6,10 @@ const validateEmail = (email: string) => {

const validatePassword = (password: string) => password.length >= 8;

const blacklist: {
id: string[];
name: string[];
} = JSON.parse(readFileSync('./src/constants/blacklist.json', 'utf-8'));
const blacklist = {
id: ['admin', 'guest'],
name: ['관리자', 'admin', 'guest'],
};

const validateId = (id: string) =>
!blacklist.id.includes(id) && /[^a-zA-Z0-9]/g.test(id) === false;
Expand Down

0 comments on commit e36af20

Please sign in to comment.