Wednesday, October 14, 2020

This way i take variable inside dockerfile, from the file in my machine, and from environment in aws

Makefile

vm:
	docker-compose --env-file .env.development up --build	
docker-compose.yaml
    build: # specify the directory of the Dockerfile
      context: .
      dockerfile: Dockerfile.dev
      args:
        - NPM_TOKEN_PARAM
        - NPM_MAIL_PARAM
        - NPM_USER_PARAM
    env_file: 
      - .env.development
. env.development
NPM_USER_PARAM=max...
NPM_TOKEN_PARAM=fe...
NPM_MAIL_PARAM=max..
Dockerfile.dev
ARG NPM_USER_PARAM
ARG NPM_TOKEN_PARAM
ARG NPM_MAIL_PARAM
ENV NPM_USER=$NPM_USER_PARAM
ENV NPM_TOKEN=$NPM_TOKEN_PARAM
ENV NPM_MAIL=$NPM_MAIL_PARAM
COPY .npmrc ./ 
RUN npm install npm-cli-login
RUN  ./node_modules/.bin/npm-cli-login -r https://npm.pkg.github.com -s @... -u ${NPM_USER} -p ${NPM_TOKEN}  -e ${NPM_MAIL}