Skip to content

Commit

Permalink
Allow Sync for non-root containers-hotreload example (#3680)
Browse files Browse the repository at this point in the history
* Allow Sync for non-root containers-hotreload example

* Allow Sync for non-root containers-hotreload example - integration dir

* backporting #3683 changes for better examples

* integration files updates of hot-reload example

* newline at the end of file

* newline at the end of file
  • Loading branch information
ibidani authored Mar 4, 2020
1 parent 56f2fe1 commit c5b9e52
Show file tree
Hide file tree
Showing 12 changed files with 122 additions and 36 deletions.
2 changes: 2 additions & 0 deletions examples/hot-reload/k8s/node.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ spec:
labels:
app: node
spec:
securityContext:
runAsUser: 1000
containers:
- name: node
image: node-example
Expand Down
2 changes: 2 additions & 0 deletions examples/hot-reload/k8s/python.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ spec:
labels:
app: python
spec:
securityContext:
runAsUser: 1000
containers:
- name: python
image: python-reload
Expand Down
15 changes: 10 additions & 5 deletions examples/hot-reload/node/Dockerfile
Original file line number Diff line number Diff line change
@@ -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* ./
COPY --chown=node:node package* ./
RUN npm ci
COPY src .
COPY --chown=node:node . .
5 changes: 3 additions & 2 deletions examples/hot-reload/node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
19 changes: 14 additions & 5 deletions examples/hot-reload/python/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +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

COPY requirements.txt .
RUN 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
36 changes: 30 additions & 6 deletions examples/hot-reload/skaffold.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: .
2 changes: 2 additions & 0 deletions integration/examples/hot-reload/k8s/node.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ spec:
labels:
app: node
spec:
securityContext:
runAsUser: 1000
containers:
- name: node
image: node-example
Expand Down
2 changes: 2 additions & 0 deletions integration/examples/hot-reload/k8s/python.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ spec:
labels:
app: python
spec:
securityContext:
runAsUser: 1000
containers:
- name: python
image: python-reload
Expand Down
15 changes: 10 additions & 5 deletions integration/examples/hot-reload/node/Dockerfile
Original file line number Diff line number Diff line change
@@ -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* ./
COPY --chown=node:node package* ./
RUN npm ci
COPY src .
COPY --chown=node:node . .
5 changes: 3 additions & 2 deletions integration/examples/hot-reload/node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
19 changes: 14 additions & 5 deletions integration/examples/hot-reload/python/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +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

COPY requirements.txt .
RUN 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
36 changes: 30 additions & 6 deletions integration/examples/hot-reload/skaffold.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: .

0 comments on commit c5b9e52

Please sign in to comment.