提交 c71854ec 编写于 作者: M Marcus Smith

Improve Angular Dockerfile, factor out configurable k8s values

上级 a8bbaeca
FROM google/dart AS build-env
WORKDIR /app
ADD pubspec.* /app/
RUN pub get --no-precompile
ADD . /app/
RUN pub get --offline --no-precompile
RUN pub build
FROM nginx
COPY ./build/web /usr/share/nginx/html
COPY --from=build-env /app/build/web /usr/share/nginx/html
COPY default.conf /etc/nginx/conf.d/default.conf
COPY nginx.conf /etc/nginx/nginx.conf
RUN groupadd -r angular
RUN useradd -m -r -g angular angular
RUN touch /var/run/nginx.pid && \
chown -R angular:angular /var/run/nginx.pid && \
chown -R angular:angular /var/cache/nginx
USER angular
EXPOSE 80
\ No newline at end of file
EXPOSE 8080
server {
listen 8080;
server_name localhost;
location / {
root /usr/share/nginx/html;
index index.html;
try_files $uri $uri/ /index.html;
}
}
\ No newline at end of file
......@@ -2,10 +2,11 @@ apiVersion: v1
kind: Service
metadata:
name: web-service
namespace: aqueduct-tutorial
namespace: $NAMESPACE
spec:
selector:
app: aqueduct-tutorial
app: $APP_NAME
role: Frontend
ports:
- port: 80
targetPort: 80
......@@ -14,31 +15,35 @@ apiVersion: apps/v1beta1
kind: Deployment
metadata:
name: web-deployment
namespace: aqueduct-tutorial
namespace: $NAMESPACE
spec:
replicas: 1
template:
metadata:
labels:
app: aqueduct-tutorial
app: $APP_NAME
role: Frontend
spec:
containers:
- name: aqueduct-tutorial
- name: $APP_NAME
imagePullPolicy: Always
image: $IMAGE_NAME
ports:
- containerPort: 80
securityContext:
runAsNonRoot: true
readOnlyRootFilesystem: true
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: tutorial-ingress
namespace: aqueduct-tutorial
name: $INGRESS_NAME
namespace: $NAMESPACE
annotations:
kubernetes.io/ingress.class: "nginx"
spec:
rules:
- host: aqueduct-tutorial.stablekernel.io
- host: $HOSTNAME
http:
paths:
- path: /
......
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
keepalive_timeout 65;
include /etc/nginx/conf.d/*.conf;
}
import 'package:angular/angular.dart';
import 'package:angular_router/angular_router.dart';
import 'package:angular_tour_of_heroes/app_component.dart';
import 'package:angular_tour_of_heroes/in_memory_data_service.dart';
import 'package:http/http.dart';
import 'package:http/browser_client.dart';
......@@ -9,21 +8,9 @@ void main() {
bootstrap(AppComponent, [
ROUTER_PROVIDERS,
// Remove next line in production
provide(LocationStrategy, useClass: HashLocationStrategy),
// provide(LocationStrategy, useClass: HashLocationStrategy),
// Using a real back end?
// Import browser_client.dart and change the above to:
provide(Client, useFactory: () => new BrowserClient(), deps: [])
]);
}
/*
import 'package:http/browser_client.dart';
void main() {
bootstrap(AppComponent, [
ROUTER_PROVIDERS,
// Remove next line in production
provide(LocationStrategy, useClass: HashLocationStrategy),
provide(BrowserClient, useFactory: () => new BrowserClient(), deps: [])
]);
}
*/
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册