From 0ed2b8176fd762a743441b668cd86ca547df31ff Mon Sep 17 00:00:00 2001 From: Dosun Yun Date: Wed, 9 Nov 2022 03:58:18 +0900 Subject: [PATCH] [BE-setup] Update dockerfile --- backend-api/.dockerignore | 119 +++++++++++++++++++++++++++++++++ backend-api/Dockerfile | 54 +++++++-------- backend-api/Dockerfile.dev | 30 +++++++++ backend-api/docker-compose.yml | 2 +- 4 files changed, 176 insertions(+), 29 deletions(-) create mode 100644 backend-api/.dockerignore create mode 100644 backend-api/Dockerfile.dev diff --git a/backend-api/.dockerignore b/backend-api/.dockerignore new file mode 100644 index 0000000..0eedb9b --- /dev/null +++ b/backend-api/.dockerignore @@ -0,0 +1,119 @@ +# Created by .ignore support plugin (hsz.mobi) +### Node template +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +lerna-debug.log* + +# Diagnostic reports (https://nodejs.org/api/report.html) +report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage +*.lcov + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# Snowpack dependency directory (https://snowpack.dev/) +web_modules/ + +# TypeScript cache +*.tsbuildinfo + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Microbundle cache +.rpt2_cache/ +.rts2_cache_cjs/ +.rts2_cache_es/ +.rts2_cache_umd/ + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variables file +.env +.env.test + +# parcel-bundler cache (https://parceljs.org/) +.cache +.parcel-cache + +# Next.js build output +.next +out + +# Nuxt.js build / generate output +.nuxt +dist + +# Gatsby files +.cache/ +# Comment in the public line in if your project uses Gatsby and not Next.js +# https://nextjs.org/blog/next-9-1#public-directory-support +# public + +# vuepress build output +.vuepress/dist + +# Serverless directories +.serverless/ + +# FuseBox cache +.fusebox/ + +# DynamoDB Local files +.dynamodb/ + +# TernJS port file +.tern-port + +# Stores VSCode versions used for testing VSCode extensions +.vscode-test + +# yarn v2 +.yarn/cache +.yarn/unplugged +.yarn/build-state.yml +.yarn/install-state.gz +.pnp.* + diff --git a/backend-api/Dockerfile b/backend-api/Dockerfile index 3302a56..5ec5bb5 100644 --- a/backend-api/Dockerfile +++ b/backend-api/Dockerfile @@ -1,30 +1,28 @@ -FROM ubuntu:18.04 - - - -RUN apt-get -qq update -RUN apt-get -qq upgrade --yes -RUN apt-get -qq install curl --yes -RUN curl -sL https://deb.nodesource.com/setup_14.x | bash - -RUN apt-get -qq install nodejs --yes - -RUN apt-get install chromium-browser --yes - -RUN useradd -ms /bin/bash frog -USER frog -WORKDIR /home/frog - -COPY package*.json ./ - -RUN npm install - +# STEP 1 NPM Build +FROM node:14 AS builder +# ORACLE 설치 +RUN apt-get update && apt-get install -y libaio1 wget unzip +WORKDIR /opt/oracle +RUN wget https://download.oracle.com/otn_software/linux/instantclient/instantclient-basiclite-linuxx64.zip && \ + unzip instantclient-basiclite-linuxx64.zip && rm -f instantclient-basiclite-linuxx64.zip && \ + cd /opt/oracle/instantclient* && rm -f *jdbc* *occi* *mysql* *mql1* *ipc1* *jar uidrvci genezi adrci && \ + echo /opt/oracle/instantclient* > /etc/ld.so.conf.d/oracle-instantclient.conf && ldconfig +#NODE Build +WORKDIR /app COPY . . -COPY tsconfig.json . -COPY tsconfig.build.json . +RUN yarn +RUN yarn build - -RUN npm run build - -EXPOSE 3000 - -CMD ["npm", "run", "start"] +# STEP 2 Running Env +FROM node:14-slim +# ORACLE 설치 +RUN apt-get update && apt-get install -y libaio1 wget unzip +WORKDIR /opt/oracle +RUN wget https://download.oracle.com/otn_software/linux/instantclient/instantclient-basiclite-linuxx64.zip && \ + unzip instantclient-basiclite-linuxx64.zip && rm -f instantclient-basiclite-linuxx64.zip && \ + cd /opt/oracle/instantclient* && rm -f *jdbc* *occi* *mysql* *mql1* *ipc1* *jar uidrvci genezi adrci && \ + echo /opt/oracle/instantclient* > /etc/ld.so.conf.d/oracle-instantclient.conf && ldconfig +WORKDIR /app +ENV NODE_ENV production +COPY --from=builder /app ./ +CMD ["yarn","start:prod"] \ No newline at end of file diff --git a/backend-api/Dockerfile.dev b/backend-api/Dockerfile.dev new file mode 100644 index 0000000..3302a56 --- /dev/null +++ b/backend-api/Dockerfile.dev @@ -0,0 +1,30 @@ +FROM ubuntu:18.04 + + + +RUN apt-get -qq update +RUN apt-get -qq upgrade --yes +RUN apt-get -qq install curl --yes +RUN curl -sL https://deb.nodesource.com/setup_14.x | bash - +RUN apt-get -qq install nodejs --yes + +RUN apt-get install chromium-browser --yes + +RUN useradd -ms /bin/bash frog +USER frog +WORKDIR /home/frog + +COPY package*.json ./ + +RUN npm install + +COPY . . +COPY tsconfig.json . +COPY tsconfig.build.json . + + +RUN npm run build + +EXPOSE 3000 + +CMD ["npm", "run", "start"] diff --git a/backend-api/docker-compose.yml b/backend-api/docker-compose.yml index dd29db9..00ad759 100644 --- a/backend-api/docker-compose.yml +++ b/backend-api/docker-compose.yml @@ -3,7 +3,7 @@ services: main: build: context: ./ - dockerfile: ./Dockerfile + dockerfile: ./Dockerfile.dev ports: - "4000:4000" networks: