Skip to content

Commit e65905b

Browse files
committed
chore: add pylon
1 parent 0cdb3fb commit e65905b

File tree

8 files changed

+327
-0
lines changed

8 files changed

+327
-0
lines changed

‎.dockerignore

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
node_modules
2+
Dockerfile*
3+
docker-compose*
4+
.dockerignore
5+
.git
6+
.gitignore
7+
README.md
8+
LICENSE
9+
.vscode
10+
Makefile
11+
helm-charts
12+
.env
13+
.editorconfig
14+
.idea
15+
coverage*

‎.github/workflows/publish.yaml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: publish
2+
3+
on: [push]
4+
env:
5+
IMAGE_NAME: cronit-app-template
6+
7+
jobs:
8+
# Push image to GitHub Packages.
9+
# See also https://docs.docker.com/docker-hub/builds/
10+
publish-container:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
packages: write
14+
contents: read
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Build image
20+
run: docker build . --file Dockerfile --tag $IMAGE_NAME
21+
22+
- name: Log into registry
23+
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
24+
25+
- name: Push image
26+
run: |
27+
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME
28+
29+
# Change all uppercase to lowercase
30+
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
31+
# Strip git ref prefix from version
32+
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
33+
# Strip "v" prefix from tag name
34+
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
35+
# Use Docker `latest` tag convention
36+
[ "$VERSION" == "main" ] && VERSION=latest
37+
echo IMAGE_ID=$IMAGE_ID
38+
echo VERSION=$VERSION
39+
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
40+
docker push $IMAGE_ID:$VERSION
41+
42+
# SPDX-License-Identifier: (EUPL-1.2)
43+
# Copyright © 2024 cronit KG

‎.gitignore

Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
# Logs
2+
3+
logs
4+
_.log
5+
npm-debug.log_
6+
yarn-debug.log*
7+
yarn-error.log*
8+
lerna-debug.log*
9+
.pnpm-debug.log*
10+
11+
# Diagnostic reports (https://nodejs.org/api/report.html)
12+
13+
report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
14+
15+
# Runtime data
16+
17+
pids
18+
_.pid
19+
_.seed
20+
\*.pid.lock
21+
22+
# Directory for instrumented libs generated by jscoverage/JSCover
23+
24+
lib-cov
25+
26+
# Coverage directory used by tools like istanbul
27+
28+
coverage
29+
\*.lcov
30+
31+
# nyc test coverage
32+
33+
.nyc_output
34+
35+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
36+
37+
.grunt
38+
39+
# Bower dependency directory (https://bower.io/)
40+
41+
bower_components
42+
43+
# node-waf configuration
44+
45+
.lock-wscript
46+
47+
# Compiled binary addons (https://nodejs.org/api/addons.html)
48+
49+
build/Release
50+
51+
# Dependency directories
52+
53+
node_modules/
54+
jspm_packages/
55+
56+
# Snowpack dependency directory (https://snowpack.dev/)
57+
58+
web_modules/
59+
60+
# TypeScript cache
61+
62+
\*.tsbuildinfo
63+
64+
# Optional npm cache directory
65+
66+
.npm
67+
68+
# Optional eslint cache
69+
70+
.eslintcache
71+
72+
# Optional stylelint cache
73+
74+
.stylelintcache
75+
76+
# Microbundle cache
77+
78+
.rpt2_cache/
79+
.rts2_cache_cjs/
80+
.rts2_cache_es/
81+
.rts2_cache_umd/
82+
83+
# Optional REPL history
84+
85+
.node_repl_history
86+
87+
# Output of 'npm pack'
88+
89+
\*.tgz
90+
91+
# Yarn Integrity file
92+
93+
.yarn-integrity
94+
95+
# dotenv environment variable files
96+
97+
.env
98+
.env.development.local
99+
.env.test.local
100+
.env.production.local
101+
.env.local
102+
103+
# parcel-bundler cache (https://parceljs.org/)
104+
105+
.cache
106+
.parcel-cache
107+
108+
# Next.js build output
109+
110+
.next
111+
out
112+
113+
# Nuxt.js build / generate output
114+
115+
.nuxt
116+
dist
117+
118+
# Gatsby files
119+
120+
.cache/
121+
122+
# Comment in the public line in if your project uses Gatsby and not Next.js
123+
124+
# https://nextjs.org/blog/next-9-1#public-directory-support
125+
126+
# public
127+
128+
# vuepress build output
129+
130+
.vuepress/dist
131+
132+
# vuepress v2.x temp and cache directory
133+
134+
.temp
135+
.cache
136+
137+
# Docusaurus cache and generated files
138+
139+
.docusaurus
140+
141+
# Serverless directories
142+
143+
.serverless/
144+
145+
# FuseBox cache
146+
147+
.fusebox/
148+
149+
# DynamoDB Local files
150+
151+
.dynamodb/
152+
153+
# TernJS port file
154+
155+
.tern-port
156+
157+
# Stores VSCode versions used for testing VSCode extensions
158+
159+
.vscode-test
160+
161+
# yarn v2
162+
163+
.yarn/cache
164+
.yarn/unplugged
165+
.yarn/build-state.yml
166+
.yarn/install-state.gz
167+
.pnp.\*
168+
169+
# wrangler project
170+
171+
.dev.vars
172+
.wrangler/
173+
174+
# Pylon project
175+
.pylon

‎Dockerfile

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Use the official Node.js 20 image as the base
2+
FROM node:20-alpine as base
3+
4+
LABEL description="Offical docker image for Pylon services (Node.js)"
5+
LABEL org.opencontainers.image.source="https://github.com/getcronit/pylon"
6+
LABEL maintainer="office@cronit.io"
7+
8+
WORKDIR /usr/src/pylon
9+
10+
# install dependencies into a temp directory
11+
# this will cache them and speed up future builds
12+
FROM base AS install
13+
RUN mkdir -p /temp/dev
14+
COPY package.json package-lock.json /temp/dev/
15+
RUN cd /temp/dev && npm ci
16+
17+
# install with --production (exclude devDependencies)
18+
RUN mkdir -p /temp/prod
19+
COPY package.json package-lock.json /temp/prod/
20+
RUN cd /temp/prod && npm ci --only=production
21+
22+
# copy node_modules from temp directory
23+
# then copy all (non-ignored) project files into the image
24+
FROM install AS prerelease
25+
COPY --from=install /temp/dev/node_modules node_modules
26+
COPY . .
27+
28+
# [optional] tests & build
29+
ENV NODE_ENV=production
30+
31+
# Create .pylon folder (mkdir)
32+
RUN mkdir -p .pylon
33+
# RUN npm test
34+
RUN npm run pylon build
35+
36+
# copy production dependencies and source code into final image
37+
FROM base AS release
38+
COPY --from=install /temp/prod/node_modules node_modules
39+
COPY --from=prerelease /usr/src/pylon/.pylon .pylon
40+
COPY --from=prerelease /usr/src/pylon/package.json .
41+
42+
# run the app
43+
USER node
44+
EXPOSE 3000/tcp
45+
ENTRYPOINT [ "node", "/usr/src/pylon/.pylon/index.js" ]

‎package.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"name": "cronit-app-template",
3+
"private": true,
4+
"version": "0.0.1",
5+
"type": "module",
6+
"description": "Generated with `npm create pylon`",
7+
"scripts": {
8+
"dev": "pylon dev -c \"node --enable-source-maps .pylon/index.js\"",
9+
"build": "pylon build"
10+
},
11+
"dependencies": {
12+
"@getcronit/pylon": "^2.0.0",
13+
"@hono/node-server": "^1.12.2"
14+
},
15+
"devDependencies": {
16+
"@getcronit/pylon-dev": "^1.0.0"
17+
},
18+
"repository": {
19+
"type": "git",
20+
"url": "https://github.com/getcronit/pylon.git"
21+
},
22+
"homepage": "https://pylon.cronit.io"
23+
}

‎pylon.d.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import '@getcronit/pylon'
2+
3+
declare module '@getcronit/pylon' {
4+
interface Bindings {}
5+
6+
interface Variables {}
7+
}

‎src/index.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import {app} from '@getcronit/pylon'
2+
import {serve} from '@hono/node-server'
3+
4+
export const graphql = {
5+
Query: {
6+
hello: () => {
7+
return 'Hello, world!'
8+
}
9+
},
10+
Mutation: {}
11+
}
12+
13+
serve(app, info => {
14+
console.log(`Server running at ${info.port}`)
15+
})

‎tsconfig.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"extends": "@getcronit/pylon/tsconfig.pylon.json",
3+
"include": ["pylon.d.ts", "src/**/*.ts"]
4+
}

0 commit comments

Comments
 (0)