-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from sehyun-hwang/fly-initial
Fly initial
- Loading branch information
Showing
26 changed files
with
1,127 additions
and
720 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
--privileged | ||
--container-options --privileged | ||
--container-daemon-socket /run/user/1000/podman/podman.sock | ||
--pull=false | ||
--artifact-server-path act/artifact | ||
-P ubuntu-latest=localhost/act | ||
--env CONTAINER_REGISTRY=nextlab.hwangsehyun.com:41443 | ||
-s GITHUB_TOKEN | ||
-e act/pull-target.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
name: Build and push express to GHCR | ||
|
||
|
||
on: | ||
push: | ||
branches-ignore: | ||
- wip/* | ||
paths: | ||
- express/** | ||
|
||
workflow_call: | ||
inputs: | ||
service-name: | ||
default: stream | ||
type: string | ||
tag: | ||
required: true | ||
type: string | ||
outputs: | ||
stream-image: | ||
value: ${{ jobs.build-push-ghcr.outputs.stream-image }} | ||
|
||
|
||
jobs: | ||
build-push-ghcr: | ||
name: Build and push to GHCR | ||
runs-on: ubuntu-latest | ||
env: | ||
TAG: ${{ github.ref_name || inputs.tag }} | ||
|
||
permissions: | ||
packages: write | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: docker compose config | ||
id: docker-compose-config | ||
run: > | ||
echo -n stream-image= >> "$GITHUB_OUTPUT" | ||
&& docker compose config --format json | jq .services.stream.image >> "$GITHUB_OUTPUT" | ||
shell: sh | ||
|
||
- name: Build a container | ||
run: docker compose build ${{ inputs.service-name || 'express' }} | ||
shell: sh | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- if: ${{ !env.ACT }} | ||
name: Login to GHCR | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Push a container to GHCR | ||
run: docker compose push ${{ inputs.service-name || 'express'}} | ||
shell: sh | ||
|
||
outputs: | ||
stream-image: ${{ steps.docker-compose-config.outputs.stream-image }} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
name: Build and push nginx to GHCR, Deploy to Pages | ||
|
||
|
||
on: | ||
push: | ||
branches-ignore: | ||
- wip/* | ||
paths: | ||
- nginx/** | ||
|
||
jobs: | ||
build-push-ghcr: | ||
uses: ./.github/workflows/express-ghcr.yml | ||
with: | ||
tag: ${{ github.ref_name }} | ||
|
||
deploy-pages: | ||
needs: build-push-ghcr | ||
environment: | ||
name: github-pages | ||
url: ${{ steps.deployment.outputs.page_url }} | ||
runs-on: ubuntu-latest | ||
|
||
permissions: | ||
contents: read | ||
pages: write | ||
id-token: write | ||
|
||
steps: | ||
- name: Export static files | ||
run: docker cp $(docker create ${{ needs.build-push-ghcr.outputs.stream-image }}):/var/www/html /tmp/pages | ||
shell: sh | ||
|
||
- name: Set API URLs | ||
working-directory: /tmp/pages | ||
run: > | ||
sed -i 's;<script src="./index.js"; | ||
<script>\n | ||
var PUB_URL = "https://imshow-express.fly.dev"\;\n | ||
var SUB_URL = "wss://imshow-nginx.fly.dev/ws/imshow"\;\n | ||
</script>\n | ||
<script src="./index.js";' | ||
index.html | ||
&& grep fly.dev index.html | ||
shell: sh | ||
|
||
- if: ${{ !env.ACT }} | ||
name: Setup Pages | ||
uses: actions/configure-pages@v3 | ||
|
||
- name: Upload Pages artifact | ||
uses: actions/upload-pages-artifact@v2 | ||
with: | ||
path: /tmp/pages | ||
|
||
- if: ${{ !env.ACT }} | ||
name: Deploy Pages | ||
id: deployment | ||
uses: actions/deploy-pages@v2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
node_modules/ | ||
dist.js | ||
|
||
act/artifact/ | ||
*.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"eslint.workingDirectories": [ | ||
{ | ||
"mode": "auto" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
FROM node:alpine | ||
|
||
COPY --from=docker/compose /usr/local/bin/docker /usr/local/bin/docker-compose /usr/local/bin/ | ||
COPY --from=docker:cli /usr/local/bin/docker /usr/local/bin/ | ||
COPY --from=docker:cli /usr/local/bin/docker-compose /root/.docker/cli-plugins/ | ||
|
||
RUN apk add jq tar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,4 +7,4 @@ | |
"ref": "act-base-ref" | ||
} | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
@sehyun-hwang:registry=https://npm.pkg.github.com | ||
//npm.pkg.github.com/:_authToken=${NODE_AUTH_TOKEN} | ||
always-auth=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,22 @@ | ||
FROM node:alpine | ||
|
||
WORKDIR /mnt | ||
COPY package.json yarn.lock ./ | ||
COPY package.json pnpm-lock.yaml .npmrc ./ | ||
|
||
RUN yarn add https://www.hwangsehyun.com/node/utils.tar.gz | ||
RUN --mount=type=secret,id=NODE_AUTH_TOKEN corepack enable pnpm \ | ||
&& NODE_AUTH_TOKEN=$(cat /run/secrets/NODE_AUTH_TOKEN) pnpm i -P --force --frozen-lockfile \ | ||
&& pnpm store prune | ||
|
||
RUN echo '#!/bin/sh' > entrypoint.sh \ | ||
&& echo exec $(NODE_AUTH_TOKEN= pnpm which express | tee /dev/stderr) '$@' >> entrypoint.sh \ | ||
&& chmod +x entrypoint.sh | ||
|
||
COPY index.js ./ | ||
|
||
LABEL express.route=/imshow | ||
LABEL org.opencontainers.image.source https://github.com/sehyun-hwang/imshow | ||
CMD ["node", "node_modules/utils/Express.js", "index.js"] | ||
LABEL express.route=/imshow \ | ||
org.opencontainers.image.source=https://github.com/sehyun-hwang/imshow | ||
|
||
EXPOSE 80 | ||
ENV PORT=80 | ||
ENTRYPOINT ["/mnt/entrypoint.sh"] | ||
CMD ["index.js"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import globals from 'globals'; | ||
|
||
export default [{ | ||
languageOptions: { | ||
globals: { | ||
...globals.nodeBuiltin, | ||
} | ||
}, | ||
rules: { | ||
'import/no-unresolved': [ | ||
'error', | ||
{ | ||
ignore: [ | ||
'got', | ||
] | ||
} | ||
] | ||
} | ||
}]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { generate } from 'random-words'; | ||
|
||
const hue = Math.random() * 360; | ||
const text = generate(3).join(' '); | ||
|
||
const svg = `<svg version="1.1" | ||
width="300" height="200" | ||
xmlns="http://www.w3.org/2000/svg"> | ||
<rect width="100%" height="100%" fill="hsl(${hue}, 100%, 50%)" /> | ||
<text x="0" y="125" font-size="100" fill="white">${text}</text> | ||
</svg>`; | ||
process.stderr.write(svg); | ||
process.stderr.write('\n'); | ||
|
||
console.log(svg); |
Oops, something went wrong.