Using A Database for Unit Testing With Docker in GitLab Pipeline

Using A Database for Unit Testing With Docker in GitLab Pipeline

Using A Database for Unit Testing With Docker in GitLab Pipeline. Recently I had the opportunity to build a CI pipeline for various microservices using GitLab. The issue comes when it’s time to run the unit test, as some of the projects does not use a mocker and would want to connect to a test DB.

Recently I had the opportunity to build a CI pipeline for various microservices using GitLab. The issue comes when it’s time to run the unit test, as some of the projects does not use a mocker and would want to connect to a test DB. Thankfully there is a way for us to generate a temporary database for testing purposes.

In this scenario, I will be using GitLab dindDocker-In-Docker (dind) to build, test and deploy the image.

Let’s start with an example Dockerfile, for this I will assume we are using a simple NodeJs project

FROM node:14-alpine AS node

## Builder stage
FROM node AS builder
ENV APP_PORT 8080
WORKDIR /app
COPY . .
## Copy .env configuration
COPY .env.test ./.env
## Install dependencies
RUN npm ci
## Port public untuk akses
EXPOSE 8080
## Run development server
CMD [ "npm", "run", "dev" ]

unit-testing docker ci-cd-pipeline gitlab

What is Geek Coin

What is GeekCash, Geek Token

Best Visual Studio Code Themes of 2021

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Creating CI/CD Pipeline With Gitlab and DigitalOcean Managed Kubernetes

Developer advocates from DigitalOcean and Axelerant discuss DigitalOcean Managed Kubernetes (DOKS) and Gitlab CI/CD pipelines, and demo how to integrate Gitlab with DOKS.

Serverless CI/CD on the AWS Cloud

To set up a serverless CI/CD pipeline in your AWS environments, there are several key services that you need to use. Find out more here.

How To Build CI/CD Pipeline With TeamCity For Selenium Test Automation

In this blog, we look at the concepts of TeamCity and how to perform Selenium test automation by integrating test suites with LambdaTest cloud-based Selenium grid. If you are still wondering about it then this article is for you.

GitLab CI/CD Pipeline | GitLab CI/CD Tutorial | Gitlab Tutorial

GitLab CI-CD Pipeline will take you through concepts of Continuous Integration, Continuous Delivery & Deployment through a very popular CI-CD tool- GitLab. You'll learn: Introduction to CI-CD; CI-CD Pipeline; GitLab CI-CD; Building a CI-CD Pipeline using GitLab

Software Testing 101: Regression Tests, Unit Tests, Integration Tests

How do scientists demonstrate that a drug or vaccine is effective? Putting it to the test. It's your only choice. And, if you're reasonable, you'd never use medications that haven't been thoroughly tested. So, why don't you test software as thoroughly as you should?