Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add demo #29

Merged
merged 4 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
node_modules
dist
dist
12 changes: 3 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
ARG NODE_IMAGE=docker.io/library/node:22-alpine

FROM $NODE_IMAGE as builder

Check warning on line 3 in Dockerfile

View workflow job for this annotation

GitHub Actions / Build Container

The 'as' keyword should match the case of the 'from' keyword

FromAsCasing: 'as' and 'FROM' keywords' casing do not match More info: https://docs.docker.com/go/dockerfile/rule/from-as-casing/

WORKDIR /app

ENV NODE_ENV production

Check warning on line 7 in Dockerfile

View workflow job for this annotation

GitHub Actions / Build Container

Legacy key/value format with whitespace separator should not be used

LegacyKeyValueFormat: "ENV key=value" should be used instead of legacy "ENV key value" format More info: https://docs.docker.com/go/dockerfile/rule/legacy-key-value-format/

# Install dependencies
COPY package.json *.lock ./
RUN if [ -f *.lock ]; then \
yarn install --frozen-lockfile --non-interactive --production false; \
else \
yarn install --non-interactive --production false; \
fi;
RUN yarn install --frozen-lockfile --non-interactive --production false

COPY . .

Expand All @@ -27,24 +23,22 @@

# ---

FROM $NODE_IMAGE as app

Check warning on line 26 in Dockerfile

View workflow job for this annotation

GitHub Actions / Build Container

The 'as' keyword should match the case of the 'from' keyword

FromAsCasing: 'as' and 'FROM' keywords' casing do not match More info: https://docs.docker.com/go/dockerfile/rule/from-as-casing/

WORKDIR /app

CMD ["yarn", "serve"]

ENV NODE_ENV production

Check warning on line 32 in Dockerfile

View workflow job for this annotation

GitHub Actions / Build Container

Legacy key/value format with whitespace separator should not be used

LegacyKeyValueFormat: "ENV key=value" should be used instead of legacy "ENV key value" format More info: https://docs.docker.com/go/dockerfile/rule/legacy-key-value-format/
ENV NODE_OPTIONS --enable-source-maps

Check warning on line 33 in Dockerfile

View workflow job for this annotation

GitHub Actions / Build Container

Legacy key/value format with whitespace separator should not be used

LegacyKeyValueFormat: "ENV key=value" should be used instead of legacy "ENV key value" format More info: https://docs.docker.com/go/dockerfile/rule/legacy-key-value-format/
# ENV ALWATR_DEBUG 1
ENV HOST 0.0.0.0

Check warning on line 34 in Dockerfile

View workflow job for this annotation

GitHub Actions / Build Container

Legacy key/value format with whitespace separator should not be used

LegacyKeyValueFormat: "ENV key=value" should be used instead of legacy "ENV key value" format More info: https://docs.docker.com/go/dockerfile/rule/legacy-key-value-format/
ENV PORT 80

Check warning on line 35 in Dockerfile

View workflow job for this annotation

GitHub Actions / Build Container

Legacy key/value format with whitespace separator should not be used

LegacyKeyValueFormat: "ENV key=value" should be used instead of legacy "ENV key value" format More info: https://docs.docker.com/go/dockerfile/rule/legacy-key-value-format/

EXPOSE 80

# Copy all deps from last stage
COPY --from=builder /app/node_modules ./node_modules

# Copy builded files from last stage
ARG PACKAGE_SOURCE
COPY --from=builder /app/package.json ./

COPY --from=builder /app/dist ./dist
RUN pwd; ls -lAhF;
8 changes: 8 additions & 0 deletions demo/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
CMS_BACKEND_IMAGE="ghcr.io/njfamirm/decap-cms-github-backend:1.1.1"
OAUTH_GITHUB_CLIENT_ID="maybe-secret"
OAUTH_GITHUB_CLIENT_SECRET="secret"
DOMAIN='decap-demo.njfamirm.ir'
OAUTH_GITHUB_SCOPE=public_repo

# Enable debug logging
CMS_BACKEND_DEBUG=1
2 changes: 2 additions & 0 deletions demo/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
*.min.js
3 changes: 3 additions & 0 deletions demo/admin/admin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import CMS from 'netlify-cms-app';

CMS.init();
13 changes: 13 additions & 0 deletions demo/admin/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="robots" content="noindex" />
<title>Website | Admin Panel</title>
<script type="module" src="/admin/admin.min.js"></script>
<link href="/config.yaml" type="text/yaml" rel="cms-config-url">
</head>
<body>
</body>
</html>
27 changes: 27 additions & 0 deletions demo/compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
networks:
internal:
alwatr-public-network:
name: alwatr-public-network
external: true

services:
cms-backend:
image: ${CMS_BACKEND_IMAGE}

restart: unless-stopped

environment:
- OAUTH_GITHUB_CLIENT_SECRET=${OAUTH_GITHUB_CLIENT_SECRET}
- OAUTH_GITHUB_CLIENT_ID=${OAUTH_GITHUB_CLIENT_ID}
- OAUTH_GITHUB_SCOPE=${OAUTH_GITHUB_SCOPE-}
- ALWATR_DEBUG=${CMS_BACKEND_DEBUG-}

networks:
alwatr-public-network:

labels:
traefik.enable: true
traefik.port: 80
traefik.frontend.rule: Host:${DOMAIN};
traefik.frontend.entryPoints: http, https
traefik.frontend.redirect.entryPoint: https
21 changes: 21 additions & 0 deletions demo/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
backend:
name: github
branch: main
repo: njfamirm/decap-cms-github-backend
base_url: https://decap-demo.njfamirm.ir/

publish_mode: editorial_workflow

media_folder: "static/uploads"
public_folder: "/uploads"

collections:
- name: blog
label: Blog
folder: "content/blog"
create: true
slug: "{{year}}-{{month}}-{{day}}-{{slug}}"
fields:
- { label: "Title", name: "title", widget: "string" }
- { label: "Date", name: "date", widget: "datetime" }
- { label: "Body", name: "body", widget: "markdown" }
35 changes: 35 additions & 0 deletions demo/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"name": "@njfamirm/decap-cms-github-backend-demo",
"author": "S. Amir Mohammad Najafi <njfamirm@gamil.com> (https://www.njfamirm.ir)",
"description": "Demo of self-hosted decap cms github backend.",
"license": "MIT",
"private": true,
"type": "module",
"scripts": {
"b": "yarn build",
"s": "yarn start",
"start": "NODE_OPTIONS=--enable-source-maps run-s clean build serve",
"build": "yarn build:es --analyze=verbose",
"build:demo": "esbuild demo/admin.js --bundle --minify --outfile=demo/admin.min.js",
"build:ts": "tsc --build",
"build:es": "esbuild src/index.ts --platform=node --external:simple-oauth2 --target=node22 --bundle --format=esm --minify --sourcemap --outdir=dist --out-extension:.js=.mjs",
"clean": "rm -rf dist build .tsbuildinfo",
"serve": "node --enable-source-maps dist/index.mjs",
"serve:debug": "node --inspect --enable-source-maps dist/index.mjs",
"watch": "run-s clean build && run-p watch:es watch:node",
"watch:node": "nodemon -w dist/ --enable-source-maps dist/index.mjs",
"watch:debug-node": "nodemon -w dist/ --inspect --enable-source-maps dist/index.mjs",
"watch:ts": "yarn build:ts --watch --preserveWatchOutput",
"watch:es": "yarn build:es --watch",
"release": "standard-version --sign"
},
"dependencies": {
"netlify-cms-app": "^2.15.72"
},
"devDependencies": {
"@types/node": "^22.10.5",
"@web/dev-server": "^0.4.6",
"esbuild": "^0.24.2"
},
"packageManager": "yarn@1.22.22+sha256.c17d3797fb9a9115bf375e31bfd30058cac6bc9c3b8807a3d8cb2094794b51ca"
}
13 changes: 13 additions & 0 deletions demo/web-dev-server.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// https://modern-web.dev/docs/dev-server/cli-and-configuration/#configuration-file

/** @type {import('@web/dev-server').DevServerConfig} */
const config = {
hostname: '0.0.0.0',
port: 8080,
watch: true,
nodeResolve: {exportConditions: ['development']},
rootDir: '.',
clearTerminalOnReload: false,
};

module.exports = config;
Loading
Loading