Welcome to our blog, today I will introduce you Build producetion app angular in docker the simplest way, to accomplish this problem you should do each of the steps below.
Step 1. Create new app in angular
Step 1. Create new app in angular
ng new DemoPushStep 2. Creata a file dockerfile in angular
FROM node:stretch-slimStep 3. Create a file docker-compore.yml
## Install http-server
RUN npm install -g superstatic
WORKDIR /app
COPY /dist/demopush .
# EXPOSE $PORT
ENTRYPOINT superstatic --host 0.0.0.0 --port 80 --gzip $USE_GZIP --debug $LOG_REQUESTS
# CMD ["superstatic" ,"--port 80"]
version: '2.3'Step 4. Create a file nginx.conf
services:
angular:
hostname: 10.199.15.93
container_name: angular-container
build: .
ports:
- 80:80
server {Now we build the docker in angular as follows:
listen 80;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri $uri/ /index.html =404;
}
ng build --prod --base-href /sample/after we build app in angular
docker build -t sample .Run below:
docker run -p 80:80 --name myapp sample
No comments:
Post a Comment