From 6bc189b2876dca88c854d2394e9702c7a852ac04 Mon Sep 17 00:00:00 2001 From: Idan Bidani Date: Sat, 29 Feb 2020 14:10:49 -0500 Subject: [PATCH] integration files updates of hot-reload example --- integration/examples/hot-reload/k8s/node.yaml | 2 ++ .../examples/hot-reload/k8s/python.yaml | 2 ++ .../examples/hot-reload/node/Dockerfile | 17 +++++---- .../examples/hot-reload/node/package.json | 5 +-- .../examples/hot-reload/python/Dockerfile | 22 ++++++++---- integration/examples/hot-reload/skaffold.yaml | 36 +++++++++++++++---- 6 files changed, 64 insertions(+), 20 deletions(-) diff --git a/integration/examples/hot-reload/k8s/node.yaml b/integration/examples/hot-reload/k8s/node.yaml index 444aa8f25c3..376fbfca72a 100644 --- a/integration/examples/hot-reload/k8s/node.yaml +++ b/integration/examples/hot-reload/k8s/node.yaml @@ -22,6 +22,8 @@ spec: labels: app: node spec: + securityContext: + runAsUser: 1000 containers: - name: node image: node-example diff --git a/integration/examples/hot-reload/k8s/python.yaml b/integration/examples/hot-reload/k8s/python.yaml index 8fcdec2f50b..64bb21d9b34 100644 --- a/integration/examples/hot-reload/k8s/python.yaml +++ b/integration/examples/hot-reload/k8s/python.yaml @@ -22,6 +22,8 @@ spec: labels: app: python spec: + securityContext: + runAsUser: 1000 containers: - name: python image: python-reload diff --git a/integration/examples/hot-reload/node/Dockerfile b/integration/examples/hot-reload/node/Dockerfile index 69d9b02619b..d411eb902d4 100644 --- a/integration/examples/hot-reload/node/Dockerfile +++ b/integration/examples/hot-reload/node/Dockerfile @@ -1,9 +1,14 @@ -FROM node:10.15.3-alpine +FROM node:12.16.0-alpine3.10 + +USER node +RUN mkdir /home/node/app +WORKDIR /home/node/app -WORKDIR /app EXPOSE 3000 -CMD ["npm", "run", "dev"] +ARG ENV=production +ENV NODE_ENV $ENV +CMD npm run $NODE_ENV -COPY package* ./ -RUN chown -R 400:400 /app && npm ci -COPY src . +COPY --chown=node:node package* ./ +RUN npm ci +COPY --chown=node:node . . diff --git a/integration/examples/hot-reload/node/package.json b/integration/examples/hot-reload/node/package.json index 2de8036ec73..e0b405435ba 100644 --- a/integration/examples/hot-reload/node/package.json +++ b/integration/examples/hot-reload/node/package.json @@ -2,9 +2,10 @@ "name": "backend", "version": "1.0.0", "description": "", - "main": "index.js", + "main": "src/index.js", "scripts": { - "dev": "nodemon index.js" + "production": "node src/index.js", + "development": "nodemon src/index.js" }, "dependencies": { "express": "^4.16.4" diff --git a/integration/examples/hot-reload/python/Dockerfile b/integration/examples/hot-reload/python/Dockerfile index 8c60022c7b6..e58bc0dc59a 100644 --- a/integration/examples/hot-reload/python/Dockerfile +++ b/integration/examples/hot-reload/python/Dockerfile @@ -1,8 +1,18 @@ FROM python:3.7.4-alpine3.10 + +RUN pip install --upgrade pip + +RUN adduser -D python +USER python +WORKDIR /home/python + +ARG DEBUG=0 +ENV FLASK_DEBUG $DEBUG +ENV FLASK_APP=src/app.py CMD ["python", "-m", "flask", "run", "--host=0.0.0.0"] -ENV FLASK_DEBUG=1 -ENV FLASK_APP=app.py -WORKDIR /usr/src/app -COPY requirements.txt . -RUN chown -R 400:400 /usr/src/app && pip install -r requirements.txt -COPY src ./ + +COPY --chown=python:python requirements.txt . +ENV PATH="/home/python/.local/bin:${PATH}" +RUN pip install --user -r requirements.txt + +COPY --chown=python:python src src diff --git a/integration/examples/hot-reload/skaffold.yaml b/integration/examples/hot-reload/skaffold.yaml index a154480440a..0724cf7af81 100644 --- a/integration/examples/hot-reload/skaffold.yaml +++ b/integration/examples/hot-reload/skaffold.yaml @@ -4,11 +4,35 @@ build: artifacts: - image: node-example context: node - sync: - infer: - - 'src/**/*.js' + - image: python-reload context: python - sync: - infer: - - 'src/**/*.py' + +profiles: + - name: dev + activation: + - command: dev + build: + artifacts: + - image: node-example + context: node + docker: + buildArgs: + ENV: development + sync: + manual: + # Sync all the javascript files that are in the src folder + # with the container src folder + - src: 'src/**/*.js' + dest: . + - image: python-reload + context: python + docker: + buildArgs: + DEBUG: 1 + sync: + manual: + # Sync all the javascript files that are in the src folder + # with the container src folder + - src: 'src/**/*.py' + dest: . \ No newline at end of file