feat: ci setup
This commit is contained in:
parent
276437e44a
commit
995eeaf09a
55
.gitlab-ci.yml
Normal file
55
.gitlab-ci.yml
Normal file
@ -0,0 +1,55 @@
|
||||
include:
|
||||
- project: "devops/pena-continuous-integration"
|
||||
file: "/templates/docker/build-template.gitlab-ci.yml"
|
||||
- project: "devops/pena-continuous-integration"
|
||||
file: "/templates/docker/clean-template.gitlab-ci.yml"
|
||||
- project: "devops/pena-continuous-integration"
|
||||
file: "/templates/docker/deploy-template.gitlab-ci.yml"
|
||||
stages:
|
||||
- clean
|
||||
- build
|
||||
- deploy
|
||||
|
||||
clear-old-images:
|
||||
extends: .clean_template
|
||||
variables:
|
||||
STAGING_BRANCH: "main"
|
||||
PRODUCTION_BRANCH: "main"
|
||||
image:
|
||||
name: docker/compose:1.28.0
|
||||
entrypoint: [""]
|
||||
before_script:
|
||||
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
|
||||
- docker images
|
||||
script:
|
||||
- docker system prune -af
|
||||
build-app:
|
||||
stage: build
|
||||
before_script:
|
||||
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
|
||||
- echo STAGING_BRANCH = $STAGING_BRANCH
|
||||
- echo CI_REGISTRY = $CI_REGISTRY
|
||||
- echo CI_REGISTRY_USER = $CI_REGISTRY_USER
|
||||
- echo CI_PROJECT_DIR = $CI_PROJECT_DIR
|
||||
- echo CI_REGISTRY_IMAGE = $CI_REGISTRY_IMAGE
|
||||
- echo CI_COMMIT_REF_SLUG = $CI_COMMIT_REF_SLUG
|
||||
- echo DOCKER_BUILD_PATH = $DOCKER_BUILD_PATH
|
||||
- echo CI_PIPELINE_ID = $CI_PIPELINE_ID
|
||||
variables:
|
||||
DOCKER_BUILD_PATH: "build/Dockerfile"
|
||||
PRODUCTION_BRANCH: main
|
||||
STAGING_BRANCH: "main"
|
||||
rules:
|
||||
- if: $CI_COMMIT_BRANCH == $PRODUCTION_BRANCH || $CI_COMMIT_BRANCH == $STAGING_BRANCH
|
||||
|
||||
script:
|
||||
- docker build -t $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG.$CI_PIPELINE_ID $CI_PROJECT_DIR
|
||||
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG.$CI_PIPELINE_ID
|
||||
|
||||
|
||||
deploy-to-staging:
|
||||
extends: .deploy_template
|
||||
variables:
|
||||
DEPLOY_TO: "staging"
|
||||
BRANCH: "main"
|
||||
|
17
Dockerfile
Normal file
17
Dockerfile
Normal file
@ -0,0 +1,17 @@
|
||||
FROM node:20.6.0-alpine as build
|
||||
|
||||
RUN apk update && rm -rf /var/cache/apk/*
|
||||
WORKDIR /usr/app
|
||||
COPY package.json .
|
||||
COPY tsconfig.json .
|
||||
|
||||
RUN yarn install --ignore-scripts --non-interactive --frozen-lockfile && yarn cache clean
|
||||
COPY . .
|
||||
RUN ls
|
||||
RUN yarn build
|
||||
|
||||
|
||||
FROM nginx:latest as result
|
||||
WORKDIR /usr/share/nginx/html
|
||||
COPY --from=build /usr/app/build/ /usr/share/nginx/html
|
||||
COPY admin.conf /etc/nginx/conf.d/default.conf
|
12
admin.conf
Normal file
12
admin.conf
Normal file
@ -0,0 +1,12 @@
|
||||
server {
|
||||
listen 80;
|
||||
server_name _;
|
||||
|
||||
location / {
|
||||
root /usr/share/nginx/html;
|
||||
index index.html index.htm;
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
|
||||
root /usr/share/nginx/html;
|
||||
}
|
0
deployments/docker-compose.yaml
Normal file
0
deployments/docker-compose.yaml
Normal file
13
deployments/staging/docker-compose.yaml
Normal file
13
deployments/staging/docker-compose.yaml
Normal file
@ -0,0 +1,13 @@
|
||||
version: "3.3"
|
||||
services:
|
||||
metrica:
|
||||
container_name: metrica_front
|
||||
restart: unless-stopped
|
||||
image: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG.$CI_PIPELINE_ID
|
||||
networks:
|
||||
- marketplace_penahub_frontend
|
||||
hostname: metrica
|
||||
tty: true
|
||||
networks:
|
||||
marketplace_penahub_frontend:
|
||||
external: true
|
Loading…
Reference in New Issue
Block a user