Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
version: 2
jobs:
build:
working_directory: /$DOCKER_REPO
docker:
- image: docker:20.10.16-git
steps:
- checkout
- setup_remote_docker
- run:
name: Install dependencies
command: |
apk add --no-cache py-pip=20.3.4-r1
pip install docker-compose==1.29.2
- run:
name: Run tests
command: |
docker-compose up -d
docker-compose run $DOCKER_REPO npm run test
- deploy:
name: Push application Docker image
command: |
docker login -u $DOCKER_USER -p $DOCKER_TOKEN
docker tag dockerapp_dockerapp $DOCKER_USER/$DOCKER_REPO:$CIRCLE_SHA1
docker tag dockerapp_dockerapp $DOCKER_USER/$DOCKER_REPO:latest
docker push $DOCKER_USER/$DOCKER_REPO:$CIRCLE_SHA1
docker push $DOCKER_USER/$DOCKER_REPO:latest
4 changes: 3 additions & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
JWT_SECRET=change_this_to_secure_your_backend
COOKIE_DOMAIN=localhost
COOKIE_DOMAIN=perro.tellaweb.io
VIRTUAL_HOST=perro.tellaweb.io
VIRTAUL_PORT=3000
54 changes: 20 additions & 34 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,36 +1,22 @@
FROM node:16.14-alpine AS development

WORKDIR /usr/src/app

RUN apk add ffmpeg

COPY package*.json ./

COPY yarn.lock ./

RUN yarn

COPY . .

RUN yarn build

FROM node:16.14-alpine as production

ARG NODE_ENV=production
ENV NODE_ENV=${NODE_ENV}

WORKDIR /usr/src/app

RUN apk add ffmpeg

COPY package*.json ./

COPY yarn.lock ./

RUN yarn --only=production

COPY . .

COPY --from=development /usr/src/app/dist ./dist
FROM node:16.14-bullseye AS base
RUN apt-get update
RUN apt-get install -y ffmpeg python libvips
RUN apt-get clean

FROM base AS build
COPY --chown=node:node package.json package-lock.json ./
RUN npm ci
COPY --chown=node:node . .
RUN npm run build

FROM node:16.14-bullseye-slim
RUN apt-get update
RUN apt-get install -y ffmpeg
RUN apt-get clean

COPY --chown=node:node --from=build package.json package-lock.json ./
COPY --chown=node:node --from=build node_modules node_modules
COPY --chown=node:node --from=build dist ./dist
RUN npm prune --production

CMD ["node", "dist/main"]
45 changes: 45 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
pipeline {
environment {
imagename = "gmarcos87/tellaweb-backend"
registryCredential = '65174897-5c07-4754-a198-ed4727630055'
dockerImage = ''
}
agent any
stages {
stage('Cloning Git') {
steps {
git([url: 'https://github.com/Horizontal-org/tellaweb-nestjs.git', branch: env.BRANCH_NAME, credentialsId: '65174897-5c07-4754-a198-ed4727630055'])

}
}
stage('Building image') {
steps{
script {
dockerImage = docker.build imagename
}
}
}

stage('Publish Image') {
when {
expression { }
}
input message: "Publish image?"
steps{
script {
docker.withRegistry( '', registryCredential ) {
dockerImage.push("$BUILD_NUMBER")
dockerImage.push('latest')
}
}
}
}
stage('Remove Unused docker image') {
steps{
sh "docker rmi $imagename:$BUILD_NUMBER"
sh "docker rmi $imagename:latest"

}
}
}
}
17 changes: 0 additions & 17 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,6 @@
version: '3.8'

services:
dev:
container_name: tellaweb_api_dev
image: tellaweb-api-dev:1.0.0
build:
context: .
target: development
dockerfile: ./Dockerfile
command: yarn start:debug
ports:
- 3001:3001
- 9229:9229
networks:
- api-network
volumes:
- .:/usr/src/app
- /usr/src/app/node_modules
restart: unless-stopped
prod:
container_name: tellaweb_api_prod
image: tellaweb-api-prod:1.0.0
Expand Down
Loading