Skip to content

Commit

Permalink
Merge pull request #12 from remotemerge/docker-dev-setup
Browse files Browse the repository at this point in the history
Docker Dev Setup
  • Loading branch information
remotemerge authored Jan 4, 2025
2 parents f8e4b4e + 2e6929d commit 6a70e7c
Show file tree
Hide file tree
Showing 23 changed files with 96 additions and 34 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest, windows-latest, macos-latest ]
os: [ ubuntu-20.04, ubuntu-22.04, ubuntu-24.04, windows-latest, macos-latest ]
node-version: [18, 20, 22]
fail-fast: false

Expand All @@ -28,10 +28,10 @@ jobs:
node-version: ${{ matrix.node-version }}

- name: Generate package.json file
run: npm init -y
run: cd html && npm init -y

- name: Install ndc package
run: npm install @remotemerge/nepali-date-converter
- name: Install Nepali Date Converter
run: cd html && npm install @remotemerge/nepali-date-converter

- name: List installed packages
run: npm list --depth=0
run: cd html && npm list --depth=0
9 changes: 6 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,15 @@ jobs:
registry-url: 'https://registry.npmjs.org'

- name: Install dependencies
run: npm install
run: cd html && npm install

- name: Build project
run: npm run build
run: cd html && npm run build

- name: Copy Documentation and License
run: cp README.md LICENSE html/dist

- name: Publish the package to npm
run: npm publish ./dist --access public
run: cd html && npm publish ./dist --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
14 changes: 7 additions & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
name: Test

# Trigger the workflow on pull requests
on: [pull_request]
on: [ pull_request ]

jobs:
test:
# Run on multiple operating systems
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
node-version: [18, 20, 22]
os: [ ubuntu-24.04, windows-latest, macos-latest ]
node-version: [ 18, 20, 22 ]
fail-fast: false

steps:
Expand All @@ -23,13 +23,13 @@ jobs:
node-version: ${{ matrix.node-version }}

- name: Install dependencies
run: npm install
run: cd html && npm install

- name: Build project
run: npm run build
run: cd html && npm run build

- name: Create data file
run: npx shx cp __tests__/data.dist.json __tests__/data.json
run: cd html && npx shx cp __tests__/data.dist.json __tests__/data.json

- name: Run Tests
run: npm run test
run: cd html && npm run test
14 changes: 7 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
### Vendor directories
/.yarn/
/node_modules/
/vendor/
/html/.yarn/
/html/node_modules/
/html/vendor/

### Build directories
/build/
/bundle/
/dist/
/html/build/
/html/bundle/
/html/dist/

### JetBrains
/.idea/*
Expand Down Expand Up @@ -56,4 +56,4 @@ pnpm-lock.yaml
yarn.lock

## Data Files
/__tests__/data.json
/html/__tests__/data.json
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![Package](https://img.shields.io/npm/v/@remotemerge/nepali-date-converter?logo=npm)](https://www.npmjs.com/package/@remotemerge/nepali-date-converter)
![Build](https://img.shields.io/github/actions/workflow/status/remotemerge/nepali-date-converter/publish.yml?logo=github)
![Tests](https://img.shields.io/github/actions/workflow/status/remotemerge/nepali-date-converter/test.yml?style=flat&logo=counterstrike&label=test)
![Tests](https://img.shields.io/github/actions/workflow/status/remotemerge/nepali-date-converter/test.yml?&logo=jest&label=test)
![Downloads](https://img.shields.io/npm/dt/@remotemerge/nepali-date-converter?logo=spreadshirt)
[![Size](https://img.shields.io/bundlephobia/minzip/@remotemerge/nepali-date-converter?logo=ipfs&label=size)](https://bundlephobia.com/result?p=@remotemerge/nepali-date-converter)
![License](https://img.shields.io/github/license/remotemerge/nepali-date-converter?logo=opensourceinitiative)
Expand Down
4 changes: 4 additions & 0 deletions app-cli.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

# Login to the app container
docker compose --file ducker-compose.yml exec --user node npm-dev-server bash
30 changes: 30 additions & 0 deletions ducker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Docker Compose configuration for NPM package deployment
# If you read this file, start docker compose with the following command:
# bash start-docker.sh

# Define network
networks:
npm-dev-network:
name: npm-dev-network
driver: bridge
external: false

# Define services
services:
npm-dev-server:
image: node:22
user: node
working_dir: /app
volumes:
- ./html/:/app
ports:
- "3000:3000"
networks:
- npm-dev-network
entrypoint: [ "/bin/bash", "/app/entrypoint.sh" ]
healthcheck:
test: [ "CMD", "curl", "-f", "http://localhost:3000" ]
interval: 30s
timeout: 10s
retries: 3
restart: unless-stopped
File renamed without changes.
2 changes: 1 addition & 1 deletion __tests__/ad.spec.ts → html/__tests__/ad.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import DateConverter from '../src/index';
import DateConverter from '../src';

import records from './data.json';

Expand Down
2 changes: 1 addition & 1 deletion __tests__/bs.spec.ts → html/__tests__/bs.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import DateConverter from '../src/index';
import DateConverter from '../src';

import records from './data.json';

Expand Down
File renamed without changes.
13 changes: 13 additions & 0 deletions html/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

# Exit on error
set -e

# Change to the app directory
cd /app

# Install dependencies
npm install

# Start the app
npm run dev
File renamed without changes.
4 changes: 2 additions & 2 deletions index.html → html/index.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Console</title>
</head>
<body>
<script type="module" src="/src/index.ts"></script>
<script type="module" src="./src/index.ts"></script>
</body>
</html>
File renamed without changes.
2 changes: 0 additions & 2 deletions maker/package-manager.ts → html/maker/package-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,3 @@ await writeFile(

// Copy static files to the dist folder
await copyFile('.npmrc', join(distPath, '.npmrc'));
await copyFile('README.md', join(distPath, 'README.md'));
await copyFile('LICENSE', join(distPath, 'LICENSE'));
4 changes: 2 additions & 2 deletions package-lock.json → html/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json → html/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@remotemerge/nepali-date-converter",
"version": "1.0.0",
"version": "1.0.1",
"description": "A modern JavaScript library for seamless conversion between Bikram Sambat (BS) and Gregorian (AD) dates. Easily convert Nepali dates to English dates and vice versa with support for years 1975 BS to 2099 BS.",
"homepage": "https://madansapkota.com",
"license": "MIT",
Expand Down Expand Up @@ -44,9 +44,9 @@
"lint": "eslint **/*.ts",
"lint:fix": "eslint **/*.ts --fix",
"test": "jest",
"dev": "vite",
"dev": "vite --host 0.0.0.0 --port 3000",
"preview": "vite preview",
"build": "vite build && npx tsx maker/package-manager.ts"
"build": "vite build && npx tsx ./maker/package-manager.ts"
},
"dependencies": {
"date-fns": "^4.1.0"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
14 changes: 14 additions & 0 deletions start-docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

# Stop and remove orphan services
docker compose --file ducker-compose.yml down --remove-orphans

# Remove dangling services
docker container prune -f
docker network prune -f
docker builder prune -f
docker image prune -f
docker volume prune -f

# Start services
docker compose --file ducker-compose.yml up

0 comments on commit 6a70e7c

Please sign in to comment.