From de2e1556a75ecc6ef8c1d12fe2e9a8976f80224c Mon Sep 17 00:00:00 2001 From: Marian Steinbach Date: Mon, 15 Oct 2018 22:18:25 +0200 Subject: [PATCH 01/12] Add Dockerfile --- Dockerfile | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..c455a16 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,10 @@ +FROM node:10-alpine + +WORKDIR /app +COPY . /app/ +RUN yarn install + +EXPOSE 8080 + +ENTRYPOINT ["node"] +CMD ["."] From 9a25e9c8d94eb09d582aed38cc25cf5caebbccaf Mon Sep 17 00:00:00 2001 From: Marian Steinbach Date: Mon, 15 Oct 2018 22:47:21 +0200 Subject: [PATCH 02/12] Add zeit.co now.json --- now.json | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 now.json diff --git a/now.json b/now.json new file mode 100644 index 0000000..0ca1cb3 --- /dev/null +++ b/now.json @@ -0,0 +1,11 @@ +{ + "env": { + "MICROPUB_TOKEN_ENDPOINT": "https://tokens.indieauth.com/token", + "MICROPUB_TOKEN_ME": "https://www.sendung.de/", + "MICROPUB_GITHUB_TOKEN": "@micropub-github-token", + "MICROPUB_GITHUB_USER": "marians", + "MICROPUB_SITE_GITHUB_REPO": "www.sendung.de", + "MICROPUB_SITE_URL": "https://www.sendung.de/", + "MICROPUB_FILENAME_STYLE": "_posts/:year-:month-:day-:slug" + } +} From 39d826796822a9a65d4dc5da5f660e65bab6f88b Mon Sep 17 00:00:00 2001 From: Marian Steinbach Date: Mon, 15 Oct 2018 22:50:36 +0200 Subject: [PATCH 03/12] More config in now.json --- now.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/now.json b/now.json index 0ca1cb3..db1a4b5 100644 --- a/now.json +++ b/now.json @@ -1,4 +1,8 @@ { + "name": "webpage-micropub-to-github", + "type": "docker", + "alias": "micropub", + "public": true, "env": { "MICROPUB_TOKEN_ENDPOINT": "https://tokens.indieauth.com/token", "MICROPUB_TOKEN_ME": "https://www.sendung.de/", From 057bc35148f2e888ef3160eeaa6d0bcd9e3171d9 Mon Sep 17 00:00:00 2001 From: Marian Steinbach Date: Mon, 15 Oct 2018 22:59:28 +0200 Subject: [PATCH 04/12] Set region --- now.json | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/now.json b/now.json index db1a4b5..98870ea 100644 --- a/now.json +++ b/now.json @@ -3,6 +3,12 @@ "type": "docker", "alias": "micropub", "public": true, + "scale": { + "bru1": { + "min": 1, + "max": 1 + } + }, "env": { "MICROPUB_TOKEN_ENDPOINT": "https://tokens.indieauth.com/token", "MICROPUB_TOKEN_ME": "https://www.sendung.de/", From ceca77dca2bb056fd665ad62d4c77ba67feae13e Mon Sep 17 00:00:00 2001 From: Marian Steinbach Date: Mon, 15 Oct 2018 23:00:17 +0200 Subject: [PATCH 05/12] Set min scaling to 0 --- now.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/now.json b/now.json index 98870ea..2ee191c 100644 --- a/now.json +++ b/now.json @@ -5,7 +5,7 @@ "public": true, "scale": { "bru1": { - "min": 1, + "min": 0, "max": 1 } }, From 3130ca1c0055507a3f57be5f1841954b0fba1109 Mon Sep 17 00:00:00 2001 From: Marian Steinbach Date: Mon, 15 Oct 2018 23:01:47 +0200 Subject: [PATCH 06/12] Set alias in now.json --- now.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/now.json b/now.json index 2ee191c..821536c 100644 --- a/now.json +++ b/now.json @@ -1,7 +1,7 @@ { "name": "webpage-micropub-to-github", "type": "docker", - "alias": "micropub", + "alias": "sendung-micropub.now.sh", "public": true, "scale": { "bru1": { From 8c364a4650d048a64a607a66e9d8468390dfe191 Mon Sep 17 00:00:00 2001 From: Marian Steinbach Date: Tue, 16 Oct 2018 09:19:39 +0200 Subject: [PATCH 07/12] Add configuration (#2) * Quote env variable value * Add configuration --- now.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/now.json b/now.json index 821536c..04046ec 100644 --- a/now.json +++ b/now.json @@ -16,6 +16,8 @@ "MICROPUB_GITHUB_USER": "marians", "MICROPUB_SITE_GITHUB_REPO": "www.sendung.de", "MICROPUB_SITE_URL": "https://www.sendung.de/", - "MICROPUB_FILENAME_STYLE": "_posts/:year-:month-:day-:slug" + "MICROPUB_FILENAME_STYLE": "\"_posts/:year-:month-:day-:slug\"", + "MICROPUB_PERMALINK_STYLE": "\":year-:month-:day-:slug\"", + "MICROPUB_MEDIA_FILES_STYLE": "\"media/:year-:month-:slug/:filesslug\"" } } From 8febe5828b4d2ab2090208172efcb910e7b212f8 Mon Sep 17 00:00:00 2001 From: Max Rydahl Andersen Date: Wed, 2 Jan 2019 00:32:21 +0100 Subject: [PATCH 08/12] cleanup --- .dockerignore | 2 ++ Dockerfile | 5 ++--- docker-compose.yml | 9 +++++++++ now.json | 34 ++++++++++++++-------------------- 4 files changed, 27 insertions(+), 23 deletions(-) create mode 100644 .dockerignore create mode 100644 docker-compose.yml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..a56a7ef --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +node_modules + diff --git a/Dockerfile b/Dockerfile index c455a16..1890816 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,9 +2,8 @@ FROM node:10-alpine WORKDIR /app COPY . /app/ -RUN yarn install +RUN npm install EXPOSE 8080 -ENTRYPOINT ["node"] -CMD ["."] +CMD ["npm", "start"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..6087eef --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,9 @@ +version: "3.1" + +services: + micropub: + image: maxandersen/webpage-micropub-to-github + ports: + - 8080:8080 + env_file: + - ./config.env diff --git a/now.json b/now.json index 04046ec..b24024f 100644 --- a/now.json +++ b/now.json @@ -1,23 +1,17 @@ { - "name": "webpage-micropub-to-github", - "type": "docker", - "alias": "sendung-micropub.now.sh", - "public": true, - "scale": { - "bru1": { - "min": 0, - "max": 1 - } - }, - "env": { - "MICROPUB_TOKEN_ENDPOINT": "https://tokens.indieauth.com/token", - "MICROPUB_TOKEN_ME": "https://www.sendung.de/", - "MICROPUB_GITHUB_TOKEN": "@micropub-github-token", - "MICROPUB_GITHUB_USER": "marians", - "MICROPUB_SITE_GITHUB_REPO": "www.sendung.de", - "MICROPUB_SITE_URL": "https://www.sendung.de/", - "MICROPUB_FILENAME_STYLE": "\"_posts/:year-:month-:day-:slug\"", - "MICROPUB_PERMALINK_STYLE": "\":year-:month-:day-:slug\"", - "MICROPUB_MEDIA_FILES_STYLE": "\"media/:year-:month-:slug/:filesslug\"" + "name": "webpage-micropub-to-github", + "alias": "xamdk-micropub.now.sh", + "public": true, + "version": 1, + "type": "docker", + "env": { + "MICROPUB_TOKEN_ENDPOINT": "https://tokens.indieauth.com/token", + "MICROPUB_TOKEN_ME": "https://xam.dk", + "MICROPUB_GITHUB_TOKEN": "@micropub-github-token", + "MICROPUB_GITHUB_USER": "maxandersen", + "MICROPUB_SITE_GITHUB_REPO": "xam.dk", + "MICROPUB_SITE_URL": "https://xam.dk", + "MICROPUB_MEDIA_FILES_STYLE": "\"media/:year-:month-:slug/:filesslug\"", + "MICROPUB_LAYOUT_NAME": "false" } } From 8432947f4e01128e02d8ff57fc4a842c351c82ec Mon Sep 17 00:00:00 2001 From: Max Rydahl Andersen Date: Wed, 2 Jan 2019 10:40:46 +0100 Subject: [PATCH 09/12] add branch support --- README.md | 17 ++++++++++++++++- now.json | 1 + 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ce7e8ff..2409cae 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,22 @@ This project contains a [https://yarnpkg.com/](Yarn) lock file which is a faster ## Installation Install as a normal Node.js application. Add the required [configuration](#configuration) values via environment variables or similar mechanism. Or deploy to Heroku: -[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy?template=https://github.com/voxpelli/webpage-micropub-to-github) +[![Deploy heroku](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy?template=https://github.com/voxpelli/webpage-micropub-to-github) + +### Deploy to now + +1. Install [now cli](https://zeit.co/download). +2. Edit `now.json` to have right values relevant for your project. + Especially make sure to change the `alias` to something unique. +3. Run `now secret add micropub-github-token ` to setup secret. +4. Run `now` to do deployment to now. +5. Run `now alias` + +This will setup a url endpoint i.e. `https://mysite-micropub.now.sh/micropub/main` +you can then use in your site. + +Note: this uses version1 of now that is based on full Docker. You'll +get warnings about this but it is okey - things still works. ## Endpoint discovery Once deployed, your Micropub endpoint can be found at `/micropub/main` e.g. `https://example.com/micropub/main`. diff --git a/now.json b/now.json index b24024f..e6a8e74 100644 --- a/now.json +++ b/now.json @@ -9,6 +9,7 @@ "MICROPUB_TOKEN_ME": "https://xam.dk", "MICROPUB_GITHUB_TOKEN": "@micropub-github-token", "MICROPUB_GITHUB_USER": "maxandersen", + "MICROPUB_GITHUB_BRANCH": "micropub", "MICROPUB_SITE_GITHUB_REPO": "xam.dk", "MICROPUB_SITE_URL": "https://xam.dk", "MICROPUB_MEDIA_FILES_STYLE": "\"media/:year-:month-:slug/:filesslug\"", From 52e7fa402d85423e9cde2a10328643e5b30e0323 Mon Sep 17 00:00:00 2001 From: Max Rydahl Andersen Date: Fri, 4 Jan 2019 08:31:47 +0100 Subject: [PATCH 10/12] reset now.json to dummy data --- now.json | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/now.json b/now.json index e6a8e74..2b66c71 100644 --- a/now.json +++ b/now.json @@ -1,18 +1,15 @@ { "name": "webpage-micropub-to-github", - "alias": "xamdk-micropub.now.sh", + "alias": "johndoe-micropub.now.sh", "public": true, "version": 1, "type": "docker", "env": { "MICROPUB_TOKEN_ENDPOINT": "https://tokens.indieauth.com/token", - "MICROPUB_TOKEN_ME": "https://xam.dk", + "MICROPUB_TOKEN_ME": "https://johndoe.example", "MICROPUB_GITHUB_TOKEN": "@micropub-github-token", - "MICROPUB_GITHUB_USER": "maxandersen", - "MICROPUB_GITHUB_BRANCH": "micropub", - "MICROPUB_SITE_GITHUB_REPO": "xam.dk", - "MICROPUB_SITE_URL": "https://xam.dk", - "MICROPUB_MEDIA_FILES_STYLE": "\"media/:year-:month-:slug/:filesslug\"", - "MICROPUB_LAYOUT_NAME": "false" + "MICROPUB_GITHUB_USER": "johndoe", + "MICROPUB_SITE_GITHUB_REPO": "johndoe.github.io", + "MICROPUB_SITE_URL": "https://johndoe.example" } } From 5ccde92af6beff37054a1d5c279a18001855637c Mon Sep 17 00:00:00 2001 From: Max Rydahl Andersen Date: Fri, 4 Jan 2019 08:37:47 +0100 Subject: [PATCH 11/12] Remove docker-compose.yml There are no publihsed docker image thus having docker-compose.yml don't make sense at this moment. --- docker-compose.yml | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 docker-compose.yml diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index 6087eef..0000000 --- a/docker-compose.yml +++ /dev/null @@ -1,9 +0,0 @@ -version: "3.1" - -services: - micropub: - image: maxandersen/webpage-micropub-to-github - ports: - - 8080:8080 - env_file: - - ./config.env From c02981ed0a4a57908d2521a201660d96841eefbf Mon Sep 17 00:00:00 2001 From: Max Rydahl Andersen Date: Fri, 4 Jan 2019 08:43:48 +0100 Subject: [PATCH 12/12] Use yarn in dockerfile Move to use yarn in docker and exclude package-lock.json from dockerfile. --- .dockerignore | 5 +++++ Dockerfile | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.dockerignore b/.dockerignore index a56a7ef..19dc0f5 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,2 +1,7 @@ node_modules +package-lock.json +/coverage +/docs +/.nyc_output + diff --git a/Dockerfile b/Dockerfile index 1890816..6e0dba2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ FROM node:10-alpine WORKDIR /app COPY . /app/ -RUN npm install +RUN yarn install --production EXPOSE 8080