Skip to content

Instantly share code, notes, and snippets.

View ravshansbox's full-sized avatar

Ravshan Samandarov ravshansbox

View GitHub Profile
name: Build Docker Image
on:
push:
branches: ['main']
jobs:
build_api:
runs-on: ubuntu-latest
steps:
const shallowEqual = (value1, value2) => {
if (Object.is(value1, value2)) {
return true;
}
const keys1 = Object.keys(value1);
const keys2 = Object.keys(value2);
if (Object.is(keys1.length, keys2.length)) {
return false;
}
services:
mongo1:
image: mongo
ports:
- 127.0.0.1:27017:27017
volumes:
- ./mongo1:/data/db
command: mongod --replSet replicaSet1
mongo2:
image: mongo
FROM node:18-alpine AS base
WORKDIR /app
COPY package.json package-lock.json ./
FROM base AS dev
RUN npm ci
COPY . ./
RUN npm run build
FROM base AS prod
FROM node:18-alpine AS build
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci
COPY . ./
RUN npm run build
RUN find ./dist -type f | xargs gzip -k
FROM nginx:1-alpine
COPY nginx.conf /etc/nginx/conf.d/default.conf
server {
gzip off;
gzip_static on;
location / {
root /usr/share/nginx/html;
try_files $uri $uri/ /index.html;
}
}
server {
listen 443;
server_name example.com;
location / {
proxy_pass http://frontend;
}
location /api {
rewrite /api/(.*) /$1 break;
proxy_pass http://backend;
proxy_set_header Host $host;
version: "3"
services:
watchtower:
image: containrrr/watchtower
restart: unless-stopped
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /root/.docker/config.json:/config.json
command: --cleanup --interval 60
swag: