Skip to content

Commit

Permalink
fix: top arg only on from include before stage
Browse files Browse the repository at this point in the history
  • Loading branch information
devthejo committed Aug 5, 2024
1 parent 71483c1 commit ab5dac9
Show file tree
Hide file tree
Showing 20 changed files with 121 additions and 77 deletions.
2 changes: 2 additions & 0 deletions src/core/generateIncluded.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ module.exports = function generateIncluded({
includePathRelative,
relativeFilePath,
includedContent,
includingInstruction,
}) {
const attrs = {
file: includePathRelative,
includedBy: relativeFilePath,
includeType: includingInstruction,
}
const attrsStr = Object.entries(attrs)
.reduce((acc, [key, value]) => {
Expand Down
1 change: 1 addition & 0 deletions src/instruction/from.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ module.exports = ({
includePathRelative,
relativeFilePath,
includedContent,
includingInstruction: "from",
}),
)
const asMatch = instruction.args.match(asMatchRegex)
Expand Down
1 change: 1 addition & 0 deletions src/instruction/fromParam.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ module.exports = ({
includePathRelative,
relativeFilePath,
includedContent,
includingInstruction: "fromParam",
}),
)

Expand Down
1 change: 1 addition & 0 deletions src/instruction/include.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ module.exports = ({
includePathRelative,
relativeFilePath,
includedContent,
includingInstruction: "include",
}),
)

Expand Down
20 changes: 20 additions & 0 deletions src/lib/parseDockerfileXStartComment.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
module.exports = function parseDockerfileXStartComment(line) {
const prefix = "# DOCKERFILE-X:START "

if (!line.startsWith(prefix)) {
return null
}

const keyValueString = line.slice(prefix.length)
const keyValuePairs = keyValueString.split(/\s+/)
const map = {}

keyValuePairs.forEach((pair) => {
const [key, value] = pair.split("=")
if (key && value) {
const cleanedValue = value.replace(/^["']|["']$/g, "")
map[key] = cleanedValue
}
})
return map
}
10 changes: 6 additions & 4 deletions src/lib/redeclareArgTop.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
const parseDockerfile = require("../lib/parseDockerfile")
const parseDockerfileXStartComment = require("../lib/parseDockerfileXStartComment")

module.exports = function redeclareArgTop(dockerContent) {
const instructions = parseDockerfile(dockerContent)

const allArgs = new Set()
let inGlobalTop = true
let inLocalTop = true
let inLocalTop = false
for (let i = 0; i < instructions.length; i++) {
const instruction = instructions[i]
switch (instruction.name) {
Expand All @@ -16,7 +17,10 @@ module.exports = function redeclareArgTop(dockerContent) {
}
case "COMMENT": {
if (instruction.raw.startsWith("# DOCKERFILE-X:START")) {
inLocalTop = true
const { includeType } = parseDockerfileXStartComment(instruction.raw)
if (includeType === "from" || includeType === "fromParam") {
inLocalTop = true
}
}
break
}
Expand All @@ -26,8 +30,6 @@ module.exports = function redeclareArgTop(dockerContent) {
}
if (inLocalTop) {
allArgs.add("ARG " + instruction.args[0])
} else {
allArgs.add("ARG " + instruction.args[0].split("=")[0])
}
break
}
Expand Down
18 changes: 8 additions & 10 deletions test/__snapshots__/COPY/copyFrom.expected.dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
ARG NODE_VERSION
ARG NODE_PACKAGE
ARG UBUNTU_VERSION=22.04
# DOCKERFILE-X:START file="./inc/node.dockerfile" includedBy="copyFrom.dockerfile"
# DOCKERFILE-X:START file="./downloader.dockerfile" includedBy="inc/node.dockerfile"
# DOCKERFILE-X:START file="ubuntu.dockerfile" includedBy="inc/downloader.dockerfile"
# DOCKERFILE-X:START file="./inc/node.dockerfile" includedBy="copyFrom.dockerfile" includeType="fromParam"
# DOCKERFILE-X:START file="./downloader.dockerfile" includedBy="inc/node.dockerfile" includeType="from"
# DOCKERFILE-X:START file="ubuntu.dockerfile" includedBy="inc/downloader.dockerfile" includeType="include"
ARG UBUNTU_VERSION=22.04
FROM ubuntu:$UBUNTU_VERSION AS nodee5203c--downlo550515--ubuntu9e4275--final-stage
FROM nodee5203c--downlo550515--ubuntu9e4275--final-stage AS nodee5203c--downlo550515--ubuntu9e4275
Expand All @@ -12,23 +10,23 @@ RUN groupadd -g 1000 ubuntu && useradd -rm -d /home/ubuntu -s /bin/bash -g ubunt
ENV HOME=/home/ubuntu
RUN chmod 0777 /home/ubuntu
RUN mkdir /app && chown 1000:1000 /app
# DOCKERFILE-X:END file="ubuntu.dockerfile" includedBy="inc/downloader.dockerfile"
# DOCKERFILE-X:END file="ubuntu.dockerfile" includedBy="inc/downloader.dockerfile" includeType="include"
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -yq --no-install-recommends curl ca-certificates wget git && rm -rf /var/lib/apt/lists/*
# DOCKERFILE-X:END file="./downloader.dockerfile" includedBy="inc/node.dockerfile"
# DOCKERFILE-X:END file="./downloader.dockerfile" includedBy="inc/node.dockerfile" includeType="from"
FROM nodee5203c--downlo550515 AS nodee5203c--build-node
# renovate: datasource=node depName=node versioning=node
ARG NODE_VERSION=20.3.0
ARG NODE_PACKAGE=node-v$NODE_VERSION-linux-x64
RUN curl https://nodejs.org/dist/v$NODE_VERSION/$NODE_PACKAGE.tar.gz | tar -xzC /opt/ && mv /opt/$NODE_PACKAGE /opt/node
# DOCKERFILE-X:START file="./ubuntu.dockerfile" includedBy="inc/node.dockerfile"
# DOCKERFILE-X:START file="./ubuntu.dockerfile" includedBy="inc/node.dockerfile" includeType="from"
ARG UBUNTU_VERSION=22.04
FROM ubuntu:$UBUNTU_VERSION AS nodee5203c--ubuntu9e4275--final-stage
FROM nodee5203c--ubuntu9e4275--final-stage AS nodee5203c--ubuntu9e4275
RUN groupadd -g 1000 ubuntu && useradd -rm -d /home/ubuntu -s /bin/bash -g ubuntu -G sudo -u 1000 ubuntu
ENV HOME=/home/ubuntu
RUN chmod 0777 /home/ubuntu
RUN mkdir /app && chown 1000:1000 /app
# DOCKERFILE-X:END file="./ubuntu.dockerfile" includedBy="inc/node.dockerfile"
# DOCKERFILE-X:END file="./ubuntu.dockerfile" includedBy="inc/node.dockerfile" includeType="from"
FROM nodee5203c--ubuntu9e4275 AS nodee5203c--final-stage
FROM nodee5203c--final-stage AS nodee5203c
COPY --from=nodee5203c--build-node /opt/node /opt/node
Expand All @@ -40,6 +38,6 @@ RUN chown 1000:1000 /yarn
ENV YARN_CACHE_FOLDER /yarn
WORKDIR /app
USER 1000
# DOCKERFILE-X:END file="./inc/node.dockerfile" includedBy="copyFrom.dockerfile"
# DOCKERFILE-X:END file="./inc/node.dockerfile" includedBy="copyFrom.dockerfile" includeType="fromParam"
FROM ubuntu:22.04
COPY --from=nodee5203c --chown=1000:1000 /opt /opt/
18 changes: 8 additions & 10 deletions test/__snapshots__/COPY/copyFromStage.expected.dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
ARG NODE_VERSION
ARG NODE_PACKAGE
ARG UBUNTU_VERSION=22.04
# DOCKERFILE-X:START file="./inc/node.dockerfile" includedBy="copyFromStage.dockerfile"
# DOCKERFILE-X:START file="./downloader.dockerfile" includedBy="inc/node.dockerfile"
# DOCKERFILE-X:START file="ubuntu.dockerfile" includedBy="inc/downloader.dockerfile"
# DOCKERFILE-X:START file="./inc/node.dockerfile" includedBy="copyFromStage.dockerfile" includeType="fromParam"
# DOCKERFILE-X:START file="./downloader.dockerfile" includedBy="inc/node.dockerfile" includeType="from"
# DOCKERFILE-X:START file="ubuntu.dockerfile" includedBy="inc/downloader.dockerfile" includeType="include"
ARG UBUNTU_VERSION=22.04
FROM ubuntu:$UBUNTU_VERSION AS nodee5203c--downlo550515--ubuntu9e4275--final-stage
FROM nodee5203c--downlo550515--ubuntu9e4275--final-stage AS nodee5203c--downlo550515--ubuntu9e4275
Expand All @@ -12,24 +10,24 @@ RUN groupadd -g 1000 ubuntu && useradd -rm -d /home/ubuntu -s /bin/bash -g ubunt
ENV HOME=/home/ubuntu
RUN chmod 0777 /home/ubuntu
RUN mkdir /app && chown 1000:1000 /app
# DOCKERFILE-X:END file="ubuntu.dockerfile" includedBy="inc/downloader.dockerfile"
# DOCKERFILE-X:END file="ubuntu.dockerfile" includedBy="inc/downloader.dockerfile" includeType="include"
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -yq --no-install-recommends curl ca-certificates wget git && rm -rf /var/lib/apt/lists/*
# DOCKERFILE-X:END file="./downloader.dockerfile" includedBy="inc/node.dockerfile"
# DOCKERFILE-X:END file="./downloader.dockerfile" includedBy="inc/node.dockerfile" includeType="from"
FROM nodee5203c--downlo550515 AS nodee5203c--build-node
FROM nodee5203c--build-node AS nodee5203c
# renovate: datasource=node depName=node versioning=node
ARG NODE_VERSION=20.3.0
ARG NODE_PACKAGE=node-v$NODE_VERSION-linux-x64
RUN curl https://nodejs.org/dist/v$NODE_VERSION/$NODE_PACKAGE.tar.gz | tar -xzC /opt/ && mv /opt/$NODE_PACKAGE /opt/node
# DOCKERFILE-X:START file="./ubuntu.dockerfile" includedBy="inc/node.dockerfile"
# DOCKERFILE-X:START file="./ubuntu.dockerfile" includedBy="inc/node.dockerfile" includeType="from"
ARG UBUNTU_VERSION=22.04
FROM ubuntu:$UBUNTU_VERSION AS nodee5203c--ubuntu9e4275--final-stage
FROM nodee5203c--ubuntu9e4275--final-stage AS nodee5203c--ubuntu9e4275
RUN groupadd -g 1000 ubuntu && useradd -rm -d /home/ubuntu -s /bin/bash -g ubuntu -G sudo -u 1000 ubuntu
ENV HOME=/home/ubuntu
RUN chmod 0777 /home/ubuntu
RUN mkdir /app && chown 1000:1000 /app
# DOCKERFILE-X:END file="./ubuntu.dockerfile" includedBy="inc/node.dockerfile"
# DOCKERFILE-X:END file="./ubuntu.dockerfile" includedBy="inc/node.dockerfile" includeType="from"
FROM nodee5203c--ubuntu9e4275 AS nodee5203c--final-stage
COPY --from=nodee5203c--build-node /opt/node /opt/node
ENV NODE_PATH /opt/node/lib/node_modules
Expand All @@ -40,6 +38,6 @@ RUN chown 1000:1000 /yarn
ENV YARN_CACHE_FOLDER /yarn
WORKDIR /app
USER 1000
# DOCKERFILE-X:END file="./inc/node.dockerfile" includedBy="copyFromStage.dockerfile"
# DOCKERFILE-X:END file="./inc/node.dockerfile" includedBy="copyFromStage.dockerfile" includeType="fromParam"
FROM ubuntu:22.04
COPY --from=nodee5203c --chown=1000:1000 /opt/node /opt/node
10 changes: 4 additions & 6 deletions test/__snapshots__/FROM/from.expected.dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
ARG NODE_VERSION
ARG NODE_PACKAGE
# DOCKERFILE-X:START file="./inc/downloader.dockerfile" includedBy="from.dockerfile"
# DOCKERFILE-X:START file="ubuntu.dockerfile" includedBy="inc/downloader.dockerfile"
# DOCKERFILE-X:START file="./inc/downloader.dockerfile" includedBy="from.dockerfile" includeType="from"
# DOCKERFILE-X:START file="ubuntu.dockerfile" includedBy="inc/downloader.dockerfile" includeType="include"
ARG UBUNTU_VERSION=22.04
FROM ubuntu:$UBUNTU_VERSION AS downlo550515--ubuntu9e4275--final-stage
FROM downlo550515--ubuntu9e4275--final-stage AS downlo550515--ubuntu9e4275
Expand All @@ -10,9 +8,9 @@ RUN groupadd -g 1000 ubuntu && useradd -rm -d /home/ubuntu -s /bin/bash -g ubunt
ENV HOME=/home/ubuntu
RUN chmod 0777 /home/ubuntu
RUN mkdir /app && chown 1000:1000 /app
# DOCKERFILE-X:END file="ubuntu.dockerfile" includedBy="inc/downloader.dockerfile"
# DOCKERFILE-X:END file="ubuntu.dockerfile" includedBy="inc/downloader.dockerfile" includeType="include"
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -yq --no-install-recommends curl ca-certificates wget git && rm -rf /var/lib/apt/lists/*
# DOCKERFILE-X:END file="./inc/downloader.dockerfile" includedBy="from.dockerfile"
# DOCKERFILE-X:END file="./inc/downloader.dockerfile" includedBy="from.dockerfile" includeType="from"
FROM downlo550515 AS final-stage
ARG NODE_VERSION=20.3.0
ARG NODE_PACKAGE=node-v$NODE_VERSION-linux-x64
Expand Down
16 changes: 16 additions & 0 deletions test/__snapshots__/FROM/fromIncludeArg.expected.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
ARG UBUNTU_VERSION=22.04
FROM debian AS node
ARG NODE_VERSION=20.3.0
ARG NODE_PACKAGE=node-v$NODE_VERSION-linux-x64
RUN curl https://nodejs.org/dist/v$NODE_VERSION/$NODE_PACKAGE.tar.gz | tar -xzC /opt/ && mv /opt/$NODE_PACKAGE /opt/node
# DOCKERFILE-X:START file="./inc/ubuntu.dockerfile" includedBy="fromIncludeArg.dockerfile" includeType="from"
ARG UBUNTU_VERSION=22.04
FROM ubuntu:$UBUNTU_VERSION AS ubuntu9e4275--final-stage
FROM ubuntu9e4275--final-stage AS ubuntu9e4275
RUN groupadd -g 1000 ubuntu && useradd -rm -d /home/ubuntu -s /bin/bash -g ubuntu -G sudo -u 1000 ubuntu
ENV HOME=/home/ubuntu
RUN chmod 0777 /home/ubuntu
RUN mkdir /app && chown 1000:1000 /app
# DOCKERFILE-X:END file="./inc/ubuntu.dockerfile" includedBy="fromIncludeArg.dockerfile" includeType="from"
FROM ubuntu9e4275 AS final-stage
COPY --from=node /opt/node /opt/node
10 changes: 4 additions & 6 deletions test/__snapshots__/FROM/fromStageAlias.expected.dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
ARG NODE_VERSION
ARG NODE_PACKAGE
# DOCKERFILE-X:START file="./inc/downloader.dockerfile" includedBy="fromStageAlias.dockerfile"
# DOCKERFILE-X:START file="ubuntu.dockerfile" includedBy="inc/downloader.dockerfile"
# DOCKERFILE-X:START file="./inc/downloader.dockerfile" includedBy="fromStageAlias.dockerfile" includeType="from"
# DOCKERFILE-X:START file="ubuntu.dockerfile" includedBy="inc/downloader.dockerfile" includeType="include"
ARG UBUNTU_VERSION=22.04
FROM ubuntu:$UBUNTU_VERSION AS downlo550515--ubuntu9e4275--final-stage
FROM downlo550515--ubuntu9e4275--final-stage AS downlo550515--ubuntu9e4275
Expand All @@ -10,9 +8,9 @@ RUN groupadd -g 1000 ubuntu && useradd -rm -d /home/ubuntu -s /bin/bash -g ubunt
ENV HOME=/home/ubuntu
RUN chmod 0777 /home/ubuntu
RUN mkdir /app && chown 1000:1000 /app
# DOCKERFILE-X:END file="ubuntu.dockerfile" includedBy="inc/downloader.dockerfile"
# DOCKERFILE-X:END file="ubuntu.dockerfile" includedBy="inc/downloader.dockerfile" includeType="include"
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -yq --no-install-recommends curl ca-certificates wget git && rm -rf /var/lib/apt/lists/*
# DOCKERFILE-X:END file="./inc/downloader.dockerfile" includedBy="fromStageAlias.dockerfile"
# DOCKERFILE-X:END file="./inc/downloader.dockerfile" includedBy="fromStageAlias.dockerfile" includeType="from"
FROM downlo550515 AS build-node
ARG NODE_VERSION=20.3.0
ARG NODE_PACKAGE=node-v$NODE_VERSION-linux-x64
Expand Down
18 changes: 8 additions & 10 deletions test/__snapshots__/FROM/fromWithTarget.expected.dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
ARG NODE_VERSION
ARG NODE_PACKAGE
ARG UBUNTU_VERSION=22.04
# DOCKERFILE-X:START file="./inc/node.dockerfile" includedBy="fromWithTarget.dockerfile"
# DOCKERFILE-X:START file="./downloader.dockerfile" includedBy="inc/node.dockerfile"
# DOCKERFILE-X:START file="ubuntu.dockerfile" includedBy="inc/downloader.dockerfile"
# DOCKERFILE-X:START file="./inc/node.dockerfile" includedBy="fromWithTarget.dockerfile" includeType="from"
# DOCKERFILE-X:START file="./downloader.dockerfile" includedBy="inc/node.dockerfile" includeType="from"
# DOCKERFILE-X:START file="ubuntu.dockerfile" includedBy="inc/downloader.dockerfile" includeType="include"
ARG UBUNTU_VERSION=22.04
FROM ubuntu:$UBUNTU_VERSION AS nodee5203c--downlo550515--ubuntu9e4275--final-stage
FROM nodee5203c--downlo550515--ubuntu9e4275--final-stage AS nodee5203c--downlo550515--ubuntu9e4275
Expand All @@ -12,24 +10,24 @@ RUN groupadd -g 1000 ubuntu && useradd -rm -d /home/ubuntu -s /bin/bash -g ubunt
ENV HOME=/home/ubuntu
RUN chmod 0777 /home/ubuntu
RUN mkdir /app && chown 1000:1000 /app
# DOCKERFILE-X:END file="ubuntu.dockerfile" includedBy="inc/downloader.dockerfile"
# DOCKERFILE-X:END file="ubuntu.dockerfile" includedBy="inc/downloader.dockerfile" includeType="include"
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -yq --no-install-recommends curl ca-certificates wget git && rm -rf /var/lib/apt/lists/*
# DOCKERFILE-X:END file="./downloader.dockerfile" includedBy="inc/node.dockerfile"
# DOCKERFILE-X:END file="./downloader.dockerfile" includedBy="inc/node.dockerfile" includeType="from"
FROM nodee5203c--downlo550515 AS nodee5203c--build-node
FROM nodee5203c--build-node AS nodee5203c
# renovate: datasource=node depName=node versioning=node
ARG NODE_VERSION=20.3.0
ARG NODE_PACKAGE=node-v$NODE_VERSION-linux-x64
RUN curl https://nodejs.org/dist/v$NODE_VERSION/$NODE_PACKAGE.tar.gz | tar -xzC /opt/ && mv /opt/$NODE_PACKAGE /opt/node
# DOCKERFILE-X:START file="./ubuntu.dockerfile" includedBy="inc/node.dockerfile"
# DOCKERFILE-X:START file="./ubuntu.dockerfile" includedBy="inc/node.dockerfile" includeType="from"
ARG UBUNTU_VERSION=22.04
FROM ubuntu:$UBUNTU_VERSION AS nodee5203c--ubuntu9e4275--final-stage
FROM nodee5203c--ubuntu9e4275--final-stage AS nodee5203c--ubuntu9e4275
RUN groupadd -g 1000 ubuntu && useradd -rm -d /home/ubuntu -s /bin/bash -g ubuntu -G sudo -u 1000 ubuntu
ENV HOME=/home/ubuntu
RUN chmod 0777 /home/ubuntu
RUN mkdir /app && chown 1000:1000 /app
# DOCKERFILE-X:END file="./ubuntu.dockerfile" includedBy="inc/node.dockerfile"
# DOCKERFILE-X:END file="./ubuntu.dockerfile" includedBy="inc/node.dockerfile" includeType="from"
FROM nodee5203c--ubuntu9e4275 AS nodee5203c--final-stage
COPY --from=nodee5203c--build-node /opt/node /opt/node
ENV NODE_PATH /opt/node/lib/node_modules
Expand All @@ -40,6 +38,6 @@ RUN chown 1000:1000 /yarn
ENV YARN_CACHE_FOLDER /yarn
WORKDIR /app
USER 1000
# DOCKERFILE-X:END file="./inc/node.dockerfile" includedBy="fromWithTarget.dockerfile"
# DOCKERFILE-X:END file="./inc/node.dockerfile" includedBy="fromWithTarget.dockerfile" includeType="from"
FROM nodee5203c AS final-stage
RUN npm i -g yarn
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
ARG NODE_VERSION
ARG NODE_PACKAGE
ARG UBUNTU_VERSION=22.04
# DOCKERFILE-X:START file="./inc/node.dockerfile" includedBy="fromWithTargetStageAlias.dockerfile"
# DOCKERFILE-X:START file="./downloader.dockerfile" includedBy="inc/node.dockerfile"
# DOCKERFILE-X:START file="ubuntu.dockerfile" includedBy="inc/downloader.dockerfile"
# DOCKERFILE-X:START file="./inc/node.dockerfile" includedBy="fromWithTargetStageAlias.dockerfile" includeType="from"
# DOCKERFILE-X:START file="./downloader.dockerfile" includedBy="inc/node.dockerfile" includeType="from"
# DOCKERFILE-X:START file="ubuntu.dockerfile" includedBy="inc/downloader.dockerfile" includeType="include"
ARG UBUNTU_VERSION=22.04
FROM ubuntu:$UBUNTU_VERSION AS nodee5203c--downlo550515--ubuntu9e4275--final-stage
FROM nodee5203c--downlo550515--ubuntu9e4275--final-stage AS nodee5203c--downlo550515--ubuntu9e4275
Expand All @@ -12,24 +10,24 @@ RUN groupadd -g 1000 ubuntu && useradd -rm -d /home/ubuntu -s /bin/bash -g ubunt
ENV HOME=/home/ubuntu
RUN chmod 0777 /home/ubuntu
RUN mkdir /app && chown 1000:1000 /app
# DOCKERFILE-X:END file="ubuntu.dockerfile" includedBy="inc/downloader.dockerfile"
# DOCKERFILE-X:END file="ubuntu.dockerfile" includedBy="inc/downloader.dockerfile" includeType="include"
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -yq --no-install-recommends curl ca-certificates wget git && rm -rf /var/lib/apt/lists/*
# DOCKERFILE-X:END file="./downloader.dockerfile" includedBy="inc/node.dockerfile"
# DOCKERFILE-X:END file="./downloader.dockerfile" includedBy="inc/node.dockerfile" includeType="from"
FROM nodee5203c--downlo550515 AS nodee5203c--build-node
FROM nodee5203c--build-node AS nodee5203c
# renovate: datasource=node depName=node versioning=node
ARG NODE_VERSION=20.3.0
ARG NODE_PACKAGE=node-v$NODE_VERSION-linux-x64
RUN curl https://nodejs.org/dist/v$NODE_VERSION/$NODE_PACKAGE.tar.gz | tar -xzC /opt/ && mv /opt/$NODE_PACKAGE /opt/node
# DOCKERFILE-X:START file="./ubuntu.dockerfile" includedBy="inc/node.dockerfile"
# DOCKERFILE-X:START file="./ubuntu.dockerfile" includedBy="inc/node.dockerfile" includeType="from"
ARG UBUNTU_VERSION=22.04
FROM ubuntu:$UBUNTU_VERSION AS nodee5203c--ubuntu9e4275--final-stage
FROM nodee5203c--ubuntu9e4275--final-stage AS nodee5203c--ubuntu9e4275
RUN groupadd -g 1000 ubuntu && useradd -rm -d /home/ubuntu -s /bin/bash -g ubuntu -G sudo -u 1000 ubuntu
ENV HOME=/home/ubuntu
RUN chmod 0777 /home/ubuntu
RUN mkdir /app && chown 1000:1000 /app
# DOCKERFILE-X:END file="./ubuntu.dockerfile" includedBy="inc/node.dockerfile"
# DOCKERFILE-X:END file="./ubuntu.dockerfile" includedBy="inc/node.dockerfile" includeType="from"
FROM nodee5203c--ubuntu9e4275 AS nodee5203c--final-stage
COPY --from=nodee5203c--build-node /opt/node /opt/node
ENV NODE_PATH /opt/node/lib/node_modules
Expand All @@ -40,6 +38,6 @@ RUN chown 1000:1000 /yarn
ENV YARN_CACHE_FOLDER /yarn
WORKDIR /app
USER 1000
# DOCKERFILE-X:END file="./inc/node.dockerfile" includedBy="fromWithTargetStageAlias.dockerfile"
# DOCKERFILE-X:END file="./inc/node.dockerfile" includedBy="fromWithTargetStageAlias.dockerfile" includeType="from"
FROM nodee5203c AS build-node
RUN npm i -g yarn
Loading

0 comments on commit ab5dac9

Please sign in to comment.