0

I have the following package.json in my Node.js project with following scripts.

{
  "name": "app",
  "version": "1.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start",
    "docker:build": "docker build -t app:latest .",
    "docker:run": "docker run -d -p 3000:3000 app"
  },
  "dependencies": { ... }
}

So I'd like to add actual version (1.1.0) as a variable to command "docker:build", so each time when I run this command I receive an image not with just latest tag, but with actual tag instead.

"docker:build": "docker build -t app:${version}."

Also, I have a .Dockerfile in my directory, so I guess if there is not option to add it as a variable in the package.json script directly there is also some option to add it via Dockerfile ENV like it does for: ENV NODE_ENV=production

As for now, I do build via IDE: enter image description here

So as far, as I understand it, it's also possible to add somekind of tag to env.

Is there a solution to solve this problem? Instead of manually tagging image after building each time?

AlexZeDim
  • 3,520
  • 2
  • 28
  • 64

0 Answers0