Giter Club home page Giter Club logo

gcloud-run-express-vue's Introduction

gcloud-run-express-vue

Nuxt.js App running on Google Cloud Run

Run on Google Cloud

For detailed explanation on how things work, check out Nuxt.js docs.

Local Development

docker-compose build
docker-compose up

Push to Google Cloud Run

docker build -t gcr.io/<project id>/gcloud-run-express-vue:v1 . --build-arg NODE_ENV=production

docker push gcr.io/<project id>/gcloud-run-express-vue:v1

gcloud beta run deploy gcloud-run-express-vue --image gcr.io/<project id>/gcloud-run-express-vue:v1 --platform managed --region asia-northeast1  --allow-unauthenticated 

How this project was created

1. Create a Dockerfile and docker-compose.yml file

FROM node:12.10

WORKDIR /usr/src/app
version: '3'

services:
  app:
    build: 
      context: .
    volumes:
      - .:/usr/src/app
    ports:
      - 8080:8080
    command: bash

2. Run the container and get bash prompt

docker-compose exec app bash

3. Install dependencies

yarn init
yarn add nuxt
yarn global add create-nuxt-app

4. Run the create-nuxt command

cd ../
yarn create-nuxt-app app

5. Update Dockerfile for production and docker-compose.yml for dev

FROM node:12.10

WORKDIR /usr/src/app

COPY . .

RUN yarn
RUN yarn build

CMD yarn start
version: '3'

services:
  app:
    build: 
      context: .
    volumes:
      - .:/usr/src/app
    ports:
      - 8080:8080
    command: yarn dev

6. Add PORT environment variable support to nuxt.config.js

server: {
    host: '0.0.0.0',
    port: process.env.PORT || 8080
}

Build Setup (from within the container)

# install dependencies
$ yarn install

# serve with hot reload at localhost:3000
$ yarn dev

# build for production and launch server
$ yarn build
$ yarn start

# generate static project
$ yarn generate

gcloud-run-express-vue's People

Contributors

ejangi avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.