Last active
May 11, 2021 23:42
-
-
Save amimaro/c2a23153794850a8c6c4ccc78539ddd2 to your computer and use it in GitHub Desktop.
NGINX configuration to deploy (Angular application) on docker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
events {} | |
http { | |
# Browser preferred language detection (does NOT require AcceptLanguageModule) | |
map $http_accept_language $accept_language { | |
~*^pt pt; | |
~*^en en; | |
} | |
server { | |
listen 80; | |
root /usr/share/nginx/html; | |
# Fallback to default language if no preference defined by browser | |
if ($accept_language ~ "^$") { | |
set $accept_language "en"; | |
} | |
# Redirect "/" to Angular app in browser's preferred language | |
rewrite ^/$ /$accept_language permanent; | |
# Everything under the Angular app is always redirected to Angular in the correct language | |
location ~ ^/(pt|en) { | |
try_files $uri /$1/index.html?$args; | |
} | |
# ... | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"node_modules" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM node:14.16.0 as build | |
WORKDIR /app | |
COPY . /app | |
RUN yarn | |
RUN yarn build-prod | |
FROM nginx | |
WORKDIR /usr/share/nginx/html | |
RUN rm -rf ./* | |
COPY ./nginx.conf /etc/nginx/nginx.conf | |
COPY --from=build /app/dist/PROJECT_NAME /usr/share/nginx/html | |
EXPOSE 80 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment