mirror of
https://github.com/Fechin/reference.git
synced 2026-11-22 05:51:48 +03:00
Multistage build
This commit is contained in:
1 parent
717795f04b
commit
e4cc8ff874
3 files changed
+17
-16
No files matched your search
@@ -0,0 +1,4 @@
|
||||
node_modules/
|
||||
*.log
|
||||
Dockerfile*
|
||||
README.md
|
||||
+11
-14
@@ -1,17 +1,14 @@
|
||||
FROM nginx:1.23.3-alpine
|
||||
|
||||
# Remove the default Nginx configuration
|
||||
RUN rm -rf /etc/nginx/conf.d/
|
||||
|
||||
# Copy our Nginx configuration
|
||||
# Stage 1: build the application
|
||||
FROM nginx:alpine AS build
|
||||
RUN rm -rf /etc/nginx/conf.d/*
|
||||
COPY nginx.conf /etc/nginx/
|
||||
|
||||
# Copy the static website
|
||||
# Use the .dockerignore file to control what ends up inside the image!
|
||||
COPY public /usr/share/nginx/html/
|
||||
EXPOSE 80
|
||||
|
||||
# Expose port 80
|
||||
EXPOSE 3000
|
||||
|
||||
# Start Nginx
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
||||
# Stage 2: final image
|
||||
FROM alpine:latest
|
||||
RUN apk add --no-cache nginx && mkdir -p /run/nginx
|
||||
COPY --from=build /usr/share/nginx/html/ /usr/share/nginx/html/
|
||||
COPY --from=build /etc/nginx/nginx.conf /etc/nginx/nginx.conf
|
||||
EXPOSE 80
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
||||
+2
-2
@@ -22,8 +22,8 @@ http {
|
||||
keepalive_timeout 65;
|
||||
|
||||
server {
|
||||
listen 3000;
|
||||
listen [::]:3000;
|
||||
listen 80;
|
||||
listen [::]:80;
|
||||
|
||||
server_name localhost;
|
||||
root /usr/share/nginx/html;
|
||||
|
||||
Reference in new issue
Block a user