From 4e72abee410a9ef889384211ecb3379926385aff Mon Sep 17 00:00:00 2001 From: Sergey Yarkov Date: Tue, 29 Mar 2022 23:43:24 +0300 Subject: [PATCH] feat: added dockerfile --- .dockerignore | 15 +++++++++++++++ Dockerfile | 18 ++++++++++++++++++ nginx/default.conf | 8 ++++++++ package.json | 2 +- src/components/UserProfile/Avatar/index.ts | 2 +- vite.config.ts | 1 + 6 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 nginx/default.conf diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..cdf631a --- /dev/null +++ b/.dockerignore @@ -0,0 +1,15 @@ +node_modules +dist +dist-ssr +coverage +stats.html +Dockerfile* +docker-compose* +.dockerignore +*.md +*.local +.git +.gitignore +.vscode +.DS_STORE +.env \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..45c7207 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,18 @@ +ARG NODE_IMAGE=node:14.17.3-alpine3.11 +ARG NGINX_IMAGE=nginx:1.16.0-alpine + +FROM ${NODE_IMAGE} as builder +WORKDIR /home/app +COPY package*.json ./ +RUN npm install +COPY . . +RUN npm run build + +FROM ${NGINX_IMAGE} as production +WORKDIR /usr/share/nginx/html +RUN rm /etc/nginx/conf.d/default.conf +COPY --from=builder /home/app/dist /usr/share/nginx/html +COPY ./nginx/default.conf /etc/nginx/conf.d/default.conf + +EXPOSE 80 +CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file diff --git a/nginx/default.conf b/nginx/default.conf new file mode 100644 index 0000000..a560219 --- /dev/null +++ b/nginx/default.conf @@ -0,0 +1,8 @@ +server { + listen 80; + location / { + root /usr/share/nginx/html; + index index.html index.htm; + try_files $uri $uri/ /index.html =404; + } +} \ No newline at end of file diff --git a/package.json b/package.json index 1baea90..71982e9 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "version": "1.0.0", "scripts": { "dev": "vite", - "build": "tsc && vite build", + "build": "vite build", "serve": "vite preview", "format": "prettier --write \"src/**/*.{js,jsx,ts,tsx}\"", "lint": "prettier --check \"src/**/*.{js,jsx,ts,tsx}\"" diff --git a/src/components/UserProfile/Avatar/index.ts b/src/components/UserProfile/Avatar/index.ts index 191590b..3b96a5b 100644 --- a/src/components/UserProfile/Avatar/index.ts +++ b/src/components/UserProfile/Avatar/index.ts @@ -3,7 +3,7 @@ import { ChatButton } from './ChatButton'; export interface IAvatarProps { name: string; - isOnline?: boolean | undefined; + isOnline?: boolean | null; } export interface IChatButtonProps { diff --git a/vite.config.ts b/vite.config.ts index 6f1fbde..6085e1f 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -20,6 +20,7 @@ export default defineConfig({ publicDir: 'public', plugins: [react()], server: { + port: 5000, proxy: { '/api': { target: constants.BACKEND_URL,