diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..f20f6b270 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,31 @@ +FROM node:14-slim + +# @see Derived from https://github.com/GoogleChrome/rendertron/issues/775 + +# Update aptitude with new repo +RUN apt-get update + +# Install software +RUN apt-get install -y git + +# Install Chromium dependencies (https://github.com/puppeteer/puppeteer/issues/1598#issuecomment-473436669) +RUN apt-get install -y libatk1.0-0 libatk-bridge2.0-0 libgtk-3-0 libgbm1 libnss3 libasound2 + +# Fetch repository +RUN git clone https://github.com/GoogleChrome/rendertron.git + +# Get inside the cloned folder +WORKDIR ./rendertron + +# Copy config.json from local filesystem to image working-dir +COPY config.json . + +# Build application +RUN npm install +RUN npm run build + +# Launch application +CMD [ "npm", "run", "start" ] + +# Expose port +EXPOSE 3000/tcp \ No newline at end of file diff --git a/README.md b/README.md index 751562188..3da533f65 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ npm run build ## デプロイ ```bash -gcloud app deploy app.yaml --project tellerapi-dev --no-promote +./deploy.sh tellerapi-dev ``` --- diff --git a/app.json b/app.json deleted file mode 100644 index e5d8806ea..000000000 --- a/app.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "name": "Rendertron", - "description": "Rendertron is a headless Chrome rendering solution designed to render & serialise web pages on the fly.", - "keywords": ["rendertron", "render", "web", "chrome"], - "website": "https://github.com/GoogleChrome/rendertron", - "buildpacks": [ - { - "url": "heroku/google-chrome" - }, - { - "url": "heroku/nodejs" - } - ] -} diff --git a/app.yaml b/app.yaml deleted file mode 100644 index 68732a46b..000000000 --- a/app.yaml +++ /dev/null @@ -1,9 +0,0 @@ -service: rendertron -runtime: nodejs12 -instance_class: F4_1G -automatic_scaling: - min_instances: 1 - max_idle_instances: 1 -env_variables: - DISABLE_LEGACY_METADATA_SERVER_ENDPOINTS: "true" - diff --git a/config.json b/config.json index 226feef49..9e26dfeeb 100644 --- a/config.json +++ b/config.json @@ -1,8 +1 @@ -{ - "cache": "datastore", - "cacheConfig": { - "cacheDurationMinutes": 1440, - "cacheMaxEntries": -1 - } -} - +{} \ No newline at end of file diff --git a/deploy.sh b/deploy.sh new file mode 100755 index 000000000..5b2a2780c --- /dev/null +++ b/deploy.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +# @see Derived from https://github.com/GoogleChrome/rendertron/issues/775 + +GOOGLE_CLOUD_PROJECT=$1 +REGION="asia-northeast1" +IMAGE="gcr.io/${GOOGLE_CLOUD_PROJECT}/rendertron" + + +# Build container image +gcloud \ + --project=${GOOGLE_CLOUD_PROJECT} \ + builds submit \ + --tag \ + $IMAGE + +# Deploy service on Cloud Run +gcloud \ + --project=${GOOGLE_CLOUD_PROJECT} \ + run deploy \ + rendertron \ + --region=${REGION} \ + --allow-unauthenticated \ + --image $IMAGE \ No newline at end of file