Skip to content

Commit fdc0343

Browse files
checkpoint managed to add docker file and to build and run the container
!
1 parent 3dba933 commit fdc0343

3 files changed

Lines changed: 126 additions & 0 deletions

File tree

Dockerfile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Stage 1: Build the Ionic app
2+
FROM node:18 AS build
3+
LABEL author="Jimmy Walker"
4+
WORKDIR /app
5+
COPY package.json package-lock.json ./
6+
RUN npm config set legacy-peer-deps true
7+
RUN npm install
8+
COPY . .
9+
RUN npm run build --prod
10+
11+
# Stage 2: Serve the app with Nginx
12+
FROM nginx:alpine
13+
COPY --from=build /app/www /usr/share/nginx/html
14+
COPY nginx.conf /etc/nginx/conf.d/default.conf
15+
EXPOSE 80
16+
CMD ["nginx", "-g", "daemon off;"]
17+
18+
# Stage 3 docker build -t ionic-example-app .
19+
# Stage 4 docker run -dp 4299:80 --name ionicExampleApp -network=internal-docker --ip=172.18.0.3 ionic-example-app

nginx.conf

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Set the default MIME type for unrecognized files to binary.
2+
#default_type application/octet-stream;
3+
4+
# Enable gzip compression to reduce transferred data size and improve performance.
5+
gzip on;
6+
gzip_comp_level 6; # Set compression level.
7+
gzip_vary on; # Add "Vary: Accept-Encoding" header.
8+
gzip_min_length 1000; # Minimum length for compression.
9+
gzip_proxied any; # Enable compression for proxied requests.
10+
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
11+
# Specify types of content to compress.
12+
gzip_buffers 16 8k; # Set gzip buffer size.
13+
14+
# Set the maximum allowed size for the client request body.
15+
client_max_body_size 256M;
16+
17+
# Set the root directory from which Nginx will serve files.
18+
root /usr/share/nginx/html;
19+
20+
# Define the server block to handle incoming requests.
21+
server {
22+
# Listen for incoming connections on all available IPv4 and IPv6 addresses on port 80.
23+
listen 0.0.0.0:80;
24+
listen [::]:80;
25+
26+
server_name localhost;
27+
28+
root /usr/share/nginx/html;
29+
index index.html;
30+
# Define how Nginx should handle requests for the root path ("/").
31+
location / {
32+
root /usr/share/nginx/html/browser;
33+
try_files $uri $uri/ /index.html =404; # Try to serve requested URI, directory index, or fallback to index.html. Return 404 if none succeed.
34+
}
35+
}

package-lock.json

Lines changed: 72 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)