Skip to content

Commit 93301e1

Browse files
author
Mubarak Imam
committed
chore(docker): add base gitlab-ci config
- refactor gitlab-ci - add command to push image to registry - add cache for node_modules
1 parent 884b6c4 commit 93301e1

File tree

3 files changed

+35
-1
lines changed

3 files changed

+35
-1
lines changed

.docker/docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ services:
88
env_file: ../nestpoc-api/production.env
99
build:
1010
context: ../nestpoc-api
11-
dockerfile: .docker/Dockerfile
11+
dockerfile: ./Dockerfile
1212
command: node /usr/nestpoc/dist/main.js
1313
volumes:
1414
- nestpoc_api:/home/node/app/node_modules

.gitlab-ci.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
image: docker:stable
2+
3+
variables:
4+
# When using dind service we need to instruct docker, to talk with the
5+
# daemon started inside of the service. The daemon is available with
6+
# a network connection instead of the default /var/run/docker.sock socket.
7+
#
8+
# The 'docker' hostname is the alias of the service container as described at
9+
# https://docs.gitlab.com/ee/ci/docker/using_docker_images.html#accessing-the-services
10+
#
11+
# Note that if you're using Kubernetes executor, the variable should be set to
12+
# tcp://localhost:2375 because of how Kubernetes executor connects services
13+
# to the job container
14+
DOCKER_HOST: tcp://docker:2375/
15+
# When using dind, it's wise to use the overlayfs driver for
16+
# improved performance.
17+
DOCKER_DRIVER: overlay2
18+
CI_REGISTRY_PATH: $CI_REGISTRY/$CI_USERNAME/$CI_PROJECT_NAME
19+
20+
services:
21+
- docker:dind
22+
23+
24+
stages:
25+
- Build Docker Image
26+
# - Push Image to Registry
27+
28+
backend:
29+
stage: Build Docker Image
30+
before_script:
31+
- docker login -u $CI_USERNAME -p $CI_ACCESS_TOKEN $CI_REGISTRY
32+
script:
33+
- docker build -t $CI_REGISTRY_PATH/$CI_BACKEND_IMG:latest ./nestpoc-api
34+
- docker push $CI_REGISTRY_PATH/$CI_BACKEND_IMG:latest
File renamed without changes.

0 commit comments

Comments
 (0)