Gcloud App Engine Flexible Weirdness with Docker and Babel

I have been deploying a node application on the server side offline to run the application for several months without any problems. The only half interesting thing about this is that running the buffer against the source when creating the container.

Over the past few weeks, this has been interrupted with an error in this deletion in the remote build log.

import * as deps from './AppFactory';
SyntaxError: Unexpected token import

Lead me to believe that the transcription of the babels does not occur; although gcloud cli indicates that this is:

> node_modules/babel-cli/bin/babel.js src/ -d dist/

src/AppFactory.js -> dist/AppFactory.js
src/Ddl.js -> dist/Ddl.js
src/Helpers.js -> dist/Helpers.js
src/MemoryResolver.js -> dist/MemoryResolver.js
src/Mysql.js -> dist/Mysql.js
src/Schema.js -> dist/Schema.js
src/index.js -> dist/index.js
 ---> 0282c805d5c9

In desperation, I exit the dist / index file in the Docker file. When I do this, I see that there is really no transpilation.

When I create a docker image in local mode, everything works fine.

My Dockerfile follows:

# Set the base image to Ubuntu
FROM    gcr.io/google_appengine/nodejs:latest

ENV NODE_ENV production

# File Author / Maintainer
# Provides cached layer for node_modules
ADD package.json /tmp/package.json
RUN cd /tmp && npm install
RUN mkdir -p /src && cp -a /tmp/node_modules /src/

# Define working directory
WORKDIR /src
ADD . /src

RUN npm run deploy
RUN cat /src/dist/index.js

CMD ["npm", "start"]

Below is my .babelrc file:

{
  "presets": [
    "es2015",
  ]
}

And my yaml vanilla file:

service: metrics-api-test
runtime: custom
env: flex
env_variables:
  NODE_ENV: 'production'
  NODEPORT: '8080'
beta_settings:
  cloud_sql_instances: pwc-sales-demos:us-east1:pawc-sales-demos-sql

babel-register, babel- node. , . , .

, . , . gcloud.

150 .

+4
1

, ; .

, babel , :

"dependencies": {
    "babel-cli": "^6.24.1",
    "babel-preset-es2015": "^6.24.1"....

. Docker:

FROM    gcr.io/google_appengine/nodejs:latest

ENV NODE_ENV production

# File Author / Maintainer
# Provides cached layer for node_modules
ADD package.json /tmp/package.json
RUN cd /tmp && npm install
RUN mkdir -p /src && cp -a /tmp/node_modules /src/

# Define working directory
WORKDIR /src
ADD . /src

RUN node_modules/babel-cli/bin/babel.js src/ -d dist/
RUN cat dist/index.js
CMD ["npm", "start"]

!

0

Source: https://habr.com/ru/post/1667314/


All Articles