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

k8s #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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 .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
.idea
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@
npm-debug.log*
yarn-debug.log*
yarn-error.log*
local.env
16 changes: 16 additions & 0 deletions deploy/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#FROM node:12.18.3-alpine3.10 as builder
#
#COPY . /src
#WORKDIR /src
#
#ENV PUBLIC_URL /service/
#RUN npm i && npm run build

#EXPOSE 3000

#CMD ["npm", "start", "--prefix", "/src"]

FROM nginx:1.19.2-alpine

COPY ./build /usr/share/nginx/html
COPY ./deploy/config.example.nginx /etc/nginx/conf.d/default.conf
9 changes: 9 additions & 0 deletions deploy/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh

DOCKER_IMAGE="${DOCKER_REGISTRY}/angry-lab/admin-front:latest"

echo "${DOCKER_PASSWORD}" | docker login -u "${DOCKER_USER}" --password-stdin "${DOCKER_REGISTRY}"

docker build -t "${DOCKER_IMAGE}" -f ./deploy/Dockerfile .
docker tag "${DOCKER_IMAGE}" admin-front:latest
docker push "${DOCKER_IMAGE}"
10 changes: 10 additions & 0 deletions deploy/config.example.nginx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
server {
listen 80;
server_name localhost;

location / {
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri $uri/ /index.html;
}
}
62 changes: 62 additions & 0 deletions deploy/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
kind: Namespace
apiVersion: v1
metadata:
name: angry
---
kind: Service
apiVersion: v1
metadata:
name: admin-front-svc
namespace: angry
spec:
selector:
app: admin-front
ports:
- port: 80
targetPort: 80
protocol: TCP
---
kind: Deployment
apiVersion: apps/v1
metadata:
name: admin-front
namespace: angry
spec:
selector:
matchLabels:
app: admin-front
template:
metadata:
labels:
app: admin-front
spec:
containers:
- name: admin-front
image: r.golangpro.ru/angry-lab/admin-front:latest
imagePullPolicy: Always
resources:
limits:
cpu: 1000m
imagePullSecrets:
- name: r-golang-pro-registry
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: admin-front-ingress
namespace: angry
annotations:
kubernetes.io/ingress.class: "nginx"
nginx.ingress.kubernetes.io/ssl-redirect: "true"
nginx.ingress.kubernetes.io/force-ssl-redirect: "true"
nginx.ingress.kubernetes.io/use-regex: "true"
nginx.ingress.kubernetes.io/rewrite-target: /$1
spec:
rules:
- host: api.golangpro.ru
http:
paths:
- path: "/service/(.*)"
backend:
serviceName: admin-front-svc
servicePort: 80
6 changes: 6 additions & 0 deletions deploy/example.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
DOCKER_REGISTRY=
DOCKER_USER=
DOCKER_PASSWORD=
DOCKER_EMAIL=

PUBLIC_URL=/service/
14 changes: 8 additions & 6 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,22 @@ import Dashboard from './pages/dashboard/Dashboard';
// import { loginRequest } from "./thunks";
// import { getIsLogged } from "./actions/getIsLogged";

const baseURL = process.env.PUBLIC_URL;
console.log(baseURL);

const App = (props) => {
//const { isLogged } = props;
//isLogged === false ? :
// login не действителен
return (

<BrowserRouter>
<Route exact path="/" component={Dashboard}/>
<BrowserRouter>
<Route exact path={baseURL} component={Dashboard}/>

<Route exact path="/login" component={Login}/>
<Route exact path="/signup" component={Registration}/>
<Route exact path="/password-recovery" component={PasswordRecovery}/>
</BrowserRouter>
<Route exact path={baseURL + "/login"} component={Login}/>
<Route exact path={baseURL + "/signup"} component={Registration}/>
<Route exact path={baseURL + "/password-recovery"} component={PasswordRecovery}/>
</BrowserRouter>
);
};

Expand Down