Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Sync for non-root containers-hotreload example #3680

Merged
merged 6 commits into from
Mar 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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: .