diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..a910ff0 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,19 @@ +# node_modules +node_modules + +# Git +.git +.gitignore +README.md + +# Tests +tests + +# Lint +.eslintrc.js +.prettierrc + +# Docker +Dockerfile +docker-compose +.dockerignore \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..b43d067 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,27 @@ +FROM node:alpine AS build + +WORKDIR /usr/app + +LABEL name="build" + +COPY package*.json ./ +COPY tsconfig*.json ./ +RUN npm install + +COPY . . + +RUN npm run build + +FROM node:alpine AS production + +WORKDIR /usr/app + +LABEL name="production" + +COPY package*.json ./ + +RUN npm install --production + +COPY --from=build /usr/app/dist ./dist + +ENTRYPOINT [ "npm", "run", "start:prod" ] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..ff421a8 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,11 @@ +version: '3' + +services: + app: + context: . + build: ./ + container_name: hub_api + ports: + - '3000:${PORT}' + env_file: + - .env