question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Confirmed integration with Node - Alpine Linux

See original GitHub issue

Which Category is your question related to? Package Installation / CI CD Usage

What AWS Services are you utilizing? I am using a vanilla installation of the Amplify CLI for Javascript (React) which only uses the Hosting plugin for serving content out of CloudFront / S3.

Provide additional details e.g. code snippets I am running the multi-environment configuration for Amplify (1.1.7) locally (MacOS, Node 10.x via NVM), and everything seems to work perfectly.

Question: Has anyone done any testing with this toolchain on a Dockerized Node environment using Alpine Linux? Is there any additional configuration or constraints to be aware of?

Background:

For the CI CD pipeline we are using GitLab CI Runners, so we configured a pretty minimal Alpine Docker image (node:10-alpine) to do some testing with the toolchain.

When running our tests in the environment I noticed some odd behaviors when running commands for both amplify init and amplify configure project via headless shell scripts. After a little bit of digging I found that just running the container and attempting a standard execution of amplify configure introduced some odd behavior.

Docker Image:

FROM node:10-alpine

RUN mkdir -p /opt/node/app/src

RUN apk -v --update add \
        python \
        py-pip \   
        git \
        yarn \
        && \
      pip install awscli --upgrade && \
      aws --version && \ 
      apk -v --purge del py-pip && \
      rm -rf /var/cache/apk/*

RUN yarn global add @aws-amplify/cli && \

WORKDIR /opt/node/app/src

Inside the Docker Container:

$ aws configure --profile default
...
$ amplify configure
? Select the backend providers. (Press <space> to select, <a> to toggle all, <i>
 to invert selection)

Note: In our pipeline usage, we are not manually configuring the AWS CLI profile, it is being automatically setup.

You can see that the behavior of the CLI prompts seems to be off, not matching the typical implementation in a local machine:

$ amplify configure
Follow these steps to set up access to your AWS account:

Sign in to your AWS administrator account:
https://console.aws.amazon.com/
Press Enter to continue
...

When I looked into the package installation from yarn global add @aws-amplify/cli I noted a few warnings related to Grunt, which possibly could be impacting some of the CLI prompts, but I don’t see anything blatantly causing an error:

$ yarn global add @aws-amplify/cli
yarn global v1.13.0
[1/4] Resolving packages...
warning @aws-amplify/cli > amplify-category-function > grunt-aws-lambda > glob > minimatch@2.0.10: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
warning @aws-amplify/cli > eslint > file-entry-cache > flat-cache > circular-json@0.3.3: CircularJSON is in maintenance only, flatted is its successor.
warning @aws-amplify/cli > amplify-category-auth > jest > jest-cli > prompts > kleur@2.0.2: Please upgrade to kleur@3 or migrate to 'ansi-colors' if you prefer the old syntax. Visit <https://github.com/lukeed/kleur/releases/tag/v3.0.0\> for migration path(s).
warning @aws-amplify/cli > amplify-category-function > grunt-aws-lambda > npm > request > node-uuid@1.4.8: Use uuid module instead
warning @aws-amplify/cli > amplify-category-function > grunt-aws-lambda > npm > request > hawk > boom@2.10.1: This version is no longer maintained. Please upgrade to the latest version.
warning @aws-amplify/cli > amplify-category-function > grunt-aws-lambda > npm > request > hawk > hoek@2.16.3: This version is no longer maintained. Please upgrade to the latest version.
warning @aws-amplify/cli > amplify-category-function > grunt-aws-lambda > npm > request > hawk > boom > hoek@2.16.3: This version is no longer maintained. Please upgrade to the latest version.
warning @aws-amplify/cli > amplify-category-function > grunt-aws-lambda > npm > request > hawk > cryptiles@2.0.5: This version is no longer maintained. Please upgrade to the latest version.
warning @aws-amplify/cli > amplify-category-function > grunt-aws-lambda > npm > request > hawk > cryptiles > boom@2.10.1: This version is no longer maintained. Please upgrade to the latest version.
warning @aws-amplify/cli > amplify-category-function > grunt-aws-lambda > npm > request > hawk > sntp > hoek@2.16.3: This version is no longer maintained. Please upgrade to the latest version.
[2/4] Fetching packages...
info There appears to be trouble with your network connection. Retrying...
info fsevents@1.2.7: The platform "linux" is incompatible with this module.
info "fsevents@1.2.7" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Installed "@aws-amplify/cli@1.1.7" with binaries:
      - amplify
Done in 143.51s.

Similarly, with the amplify init command being executed on an existing project, I saw an odd behavior when trying to pass in the arguments for providers:

$ ./docker/gitlab-ci/scripts/amplify-init.sh
Note: It is recommended to run this command from the root of your app directory
Using default provider  undefined
init failed
TypeError [ERR_INVALID_ARG_TYPE]: The "id" argument must be of type string. Received type undefined
    at Module.require (internal/modules/cjs/loader.js:631:11)
    at require (internal/modules/cjs/helpers.js:22:18)
    at providers.forEach (/usr/local/share/.config/yarn/global/node_modules/@aws-amplify/cli/src/lib/init-steps/s2-initProviders.js:13:28)
    at Array.forEach (<anonymous>)
    at run (/usr/local/share/.config/yarn/global/node_modules/@aws-amplify/cli/src/lib/init-steps/s2-initProviders.js:12:13)
    at process._tickCallback (internal/process/next_tick.js:68:7)
    at Function.Module.runMain (internal/modules/cjs/loader.js:745:11)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:743:3)

I performed a cat and echo on the variables being set in the shell script, and all of the JSON appears to substitute/expand properly and meet formatting requirements.

Conclusion: Well, not much a conclusion on my part other than continuing to explore the problem space using an ubuntu based Docker image; however, if anyone has explored an installation with Alpine Linux, I’d greatly appreciate some thoughts.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
mark-schaalcommented, Mar 19, 2019

Since we are using a multi-tenant GitLab CI, we currently have two init scripts: one to setup the AWS CLI client, and the other to setup the Amplify environments.

awscli-init.sh

#!/bin/sh
#
# awscli-init.sh - Configures AWS-CLI Profile from envvars.
#
# The AWS Amplify tooling requires an AWS CLI profile
# to initialize projects correctly. This script uses envvars
# from the GitLab CI runner to setup the credentials and config files.

set -e 

# Set the ~/.aws/credentials file.
aws configure set aws_access_key_id $AWS_ACCESS_KEY_ID --profile default
aws configure set aws_secret_access_key $AWS_SECRET_ACCESS_KEY --profile default
aws configure set aws_access_key_id $AWS_ACCESS_KEY_ID --profile $AWS_PROFILE_NAME
aws configure set aws_secret_access_key $AWS_SECRET_ACCESS_KEY --profile $AWS_PROFILE_NAME

# Set the ~/.aws/
aws configure set default.region us-east-1 --profile default
aws configure set default.output json --profile default
aws configure set default.region us-east-1 --profile $AWS_PROFILE_NAME
aws configure set default.output json --profile $AWS_PROFILE_NAME

amplify-init.sh

#!/bin/sh
set -e
IFS='|'

REACTCONFIG="{\
  \"SourceDir\": \"src\",\
  \"DistributionDir\": \"build\",\
  \"BuildCommand\": \"yarn build\",\
  \"StartCommand\": \"yarn start\"\
}"

AWSCLOUDFORMATIONCONFIG="{\
  \"configLevel\": \"project\",\
  \"useProfile\": true,\
  \"profileName\": \"default\",\
  \"region\": \"us-east-1\"\
}"

AMPLIFY="{\
  \"projectName\": \"project-name-here\",\
  \"envName\": \"$AMPLIFY_ENV_NAME\",\
  \"defaultEditor\": \"code\"\
}"

FRONTEND="{\
  \"frontend\": \"javascript\",\
  \"framework\": \"react\",\
  \"config\": $REACTCONFIG\
}"

PROVIDERS="{\
  \"awscloudformation\": $AWSCLOUDFORMATIONCONFIG\
}"

amplify init \
--amplify $AMPLIFY \
--frontend $FRONTEND \
--providers $PROVIDERS \
--yes

Note that the Amplify init script is almost identical to the recommendations in this repository for headless operations.

0reactions
github-actions[bot]commented, May 27, 2021

This issue has been automatically locked since there hasn’t been any recent activity after it was closed. Please open a new issue for related bugs.

Looking for a help forum? We recommend joining the Amplify Community Discord server *-help channels for those types of questions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Alpine Linux 3.17.0 Released
Alpine Linux 3.17.0 Released. We are pleased to announce the release of Alpine Linux 3.17.0, the first in the v3.17 stable series.
Read more >
How To Build a Node.js Application with Docker - DigitalOcean
Interested in Node.js but not sure where to start with Docker? ... file by typing CTRL + X . Press Y and then...
Read more >
Docker for Node.js Developers: 5 Things You Need to Know ...
Learn from Docker experts to simplify and advance your app development and management with Docker. Stay up to date on Docker events and...
Read more >
Using Docker for Node.js in Development and Production
The instructions for the first stage FROM node:10-alpine as builder ARG NODE_ENV=development ENV NODE_ENV=${NODE_ENV} RUN apk --no-cache add ...
Read more >
How to build a Node.js and MongoDB Application with Docker ...
Docker is the world's leading software container platform. ... FROM alpine:latest ... Case Study : Integrate Node.js + MongoDB application with Docker.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found