Skip to content

Commit

Permalink
Initial version
Browse files Browse the repository at this point in the history
  • Loading branch information
fileformat committed Oct 17, 2024
1 parent 1bd23f7 commit 738a018
Show file tree
Hide file tree
Showing 13 changed files with 1,236 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# EditorConfig is awesome: http://EditorConfig.org

# top-most EditorConfig file
root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

[*.yaml]
indent_size = 2

[*.json]
indent_size = 2
64 changes: 64 additions & 0 deletions .github/workflows/gcr-deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: deploy

on:
push:
branches:
- main

workflow_dispatch:

# Environment variables available to all jobs and steps in this workflow
# NOTE: these aren't really secret, but there aren't non-secret settings
env:
RUN_PROJECT: ${{ secrets.RUN_PROJECT }}
RUN_REGION: ${{ secrets.RUN_REGION }}
RUN_SERVICE: ${{ secrets.RUN_SERVICE }}

jobs:
deploy:
name: Deploy to CloudRun
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: gcloud auth
id: 'auth'
uses: 'google-github-actions/auth@v2'
with:
credentials_json: '${{ secrets.GCP_SA_KEY }}'

# Setup gcloud CLI
- name: gcloud setup
uses: google-github-actions/setup-gcloud@v2

- name: gcloud docker-auth
run: gcloud auth configure-docker

# Build and push image to Google Container Registry
- name: Build
run: |
docker build \
--build-arg COMMIT=${GITHUB_SHA:0:7} \
--build-arg LASTMOD=$(date -u +%Y-%m-%dT%H:%M:%SZ) \
--tag gcr.io/${RUN_PROJECT}/${RUN_SERVICE}:$GITHUB_SHA \
.
- name: GCloud auth to docker
run: |
gcloud auth configure-docker
- name: Push to registry
run: |
docker push gcr.io/${RUN_PROJECT}/${RUN_SERVICE}:$GITHUB_SHA
# Deploy image to Cloud Run
- name: Deploy
run: |
gcloud run deploy ${RUN_SERVICE} \
--allow-unauthenticated \
--image gcr.io/${RUN_PROJECT}/${RUN_SERVICE}:$GITHUB_SHA \
--platform managed \
--project ${RUN_PROJECT} \
--region ${RUN_REGION}
15 changes: 15 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
*~
.cache
dist
.DS_Store
*.env
*.gz
jspm_packages/
logs
*.log
node_modules/
.swp
*.tgz
tmp
*.tmp
*.zip
29 changes: 29 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
FROM denoland/deno:debian AS builder

WORKDIR /app

COPY . .

RUN deno compile \
--allow-env \
--allow-net \
--allow-read \
src/server.ts


FROM gcr.io/distroless/cc

USER nonroot
WORKDIR /app
ARG COMMIT="(not set)"
ARG LASTMOD="(not set)"
ENV COMMIT=$COMMIT
ENV LASTMOD=$LASTMOD

COPY --from=builder /app/server /app/server
COPY ./static /app/static

ENV PORT=4000
ENV HOSTNAME=0.0.0.0

CMD ["/app/server"]
Loading

0 comments on commit 738a018

Please sign in to comment.