Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/dockerfile #822

Merged
merged 7 commits into from
Dec 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@

node_modules/
/dist/
.idea/
.vscode/
.git/
.github/

npm-debug.log*
yarn-debug.log*
yarn-error.log*
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
.DS_Store

.editorconfig
.eslintrc.js
.gitignore
.prettierrc.js
.babel.config.js
.jest.config.js
.postcss.config.js
.vetur.config.js
.vue.config.js
.env
.env.local
.env.*.local

/tests/

Dockerfile
76 changes: 19 additions & 57 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,70 +1,32 @@
FROM node:14-alpine as builder
# syntax = docker/dockerfile:1

ENV WORKDIR /home/app
WORKDIR $WORKDIR
ARG NODE_VERSION="14.17.4"
ARG BASE_VERSION="alpine3.14"

RUN apk update && apk add git yarn
FROM node:${NODE_VERSION}-${BASE_VERSION} as builder

COPY package.json .
COPY yarn.lock .
WORKDIR /home/app

RUN yarn install --network-timeout 1000000
RUN apk --no-cache add git

COPY . .
COPY package.json yarn.lock ./

ARG VUE_APP_ROOT_API
ARG KEYCLOAK_ISSUER
ARG KEYCLOAK_AUTHORIZATION_ENDPOINT
ARG KEYCLOAK_USERINFO_ENDPOINT
ARG KEYCLOAK_END_SESSION_ENDPOINT
ARG KEYCLOAK_JWKS_URI
ARG KEYCLOAK_TOKEN_ENDPOINT
ARG KEYCLOAK_CHECK_SESSION_IFRAME
ARG KEYCLOAK_CLIENT_ID
ARG KEYCLOAK_REALM
ARG VUE_APP_HOTJAR_PROJECT_KEY
ARG VUE_APP_BOT_URL
ARG VUE_APP_SENTRY_DSN_ENDPOINT
ARG VUE_APP_HELPHERO
ARG VUE_APP_STRIPE_API
ARG LOGROCKET_ID
ARG LOGROCKET_CHILD_DOMAINS
ARG VUE_APP_URL_ACADEMY
ARG MP9_AB_MAPPING_TOKEN
RUN --mount=type=cache,target=/root/.yarn \
YARN_CACHE_FOLDER=/root/.yarn yarn install

ENV VUE_APP_ROOT_API "${VUE_APP_ROOT_API}"
ENV KEYCLOAK_ISSUER "${KEYCLOAK_ISSUER}"
ENV KEYCLOAK_AUTHORIZATION_ENDPOINT "${KEYCLOAK_AUTHORIZATION_ENDPOINT}"
ENV KEYCLOAK_USERINFO_ENDPOINT "${KEYCLOAK_USERINFO_ENDPOINT}"
ENV KEYCLOAK_END_SESSION_ENDPOINT "${KEYCLOAK_END_SESSION_ENDPOINT}"
ENV KEYCLOAK_JWKS_URI "${KEYCLOAK_JWKS_URI}"
ENV KEYCLOAK_TOKEN_ENDPOINT "${KEYCLOAK_TOKEN_ENDPOINT}"
ENV KEYCLOAK_CHECK_SESSION_IFRAME "${KEYCLOAK_CHECK_SESSION_IFRAME}"
ENV KEYCLOAK_CLIENT_ID "${KEYCLOAK_CLIENT_ID}"
ENV KEYCLOAK_REALM "${KEYCLOAK_REALM}"
ENV VUE_APP_HOTJAR_PROJECT_KEY "${VUE_APP_HOTJAR_PROJECT_KEY}"
ENV VUE_APP_BOT_URL "${VUE_APP_BOT_URL}"
ENV VUE_APP_SENTRY_DSN_ENDPOINT "${VUE_APP_SENTRY_DSN_ENDPOINT}"
ENV VUE_APP_HELPHERO "${VUE_APP_HELPHERO}"
ENV VUE_APP_STRIPE_API "${VUE_APP_STRIPE_API}"
ENV LOGROCKET_ID "${LOGROCKET_ID}"
ENV LOGROCKET_CHILD_DOMAINS "${LOGROCKET_CHILD_DOMAINS}"
ENV VUE_APP_URL_ACADEMY "${VUE_APP_URL_ACADEMY}"
ENV MP9_AB_MAPPING_TOKEN "${MP9_AB_MAPPING_TOKEN}"
COPY . ./

RUN yarn build

FROM nginx
FROM nginxinc/nginx-unprivileged:1.25-alpine

COPY nginx.conf /etc/nginx/nginx.conf
COPY --from=builder /home/app/dist /usr/share/nginx/html/connect

COPY docker-entrypoint.sh /usr/share/nginx/

RUN chmod +x /usr/share/nginx/docker-entrypoint.sh

ENTRYPOINT ["/usr/share/nginx/docker-entrypoint.sh"]
COPY --chown=nginx:nginx nginx.conf /etc/nginx/nginx.conf
COPY --from=builder --chown=nginx:nginx /home/app/dist /usr/share/nginx/html/connect/
COPY docker-entrypoint.sh /
RUN mv /usr/share/nginx/html/connect/index.html /usr/share/nginx/html/connect/index.html.tmpl \
&& cd /usr/share/nginx/html/connect/ \
&& ln -s /tmp/index.html

EXPOSE 8080
ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["nginx", "-g", "daemon off;"]

# COPY config.js.tmpl /usr/share/nginx/html/connect/
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ services:
- VUE_APP_URL_ACADEMY=${VUE_APP_URL_ACADEMY}
- MP9_AB_MAPPING_TOKEN=${MP9_AB_MAPPING_TOKEN}
ports:
- 80:80
- 8080:8080
2 changes: 1 addition & 1 deletion docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ export JSON_STRING='window.configs = { \
"FLOWS_GENERIC_TOKEN":"'${FLOWS_GENERIC_TOKEN}'", \
"MODULES_YAML":"'${MODULES_YAML}'", \
}'
sed -i "s|\/\/CONFIGURATIONS_PLACEHOLDER|${JSON_STRING}|" /usr/share/nginx/html/connect/index.html
sed "s|\/\/CONFIGURATIONS_PLACEHOLDER|${JSON_STRING}|" /usr/share/nginx/html/connect/index.html.tmpl > /tmp/index.html

exec "$@"
19 changes: 14 additions & 5 deletions nginx.conf
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
user nginx;
worker_processes 1;

error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
error_log /dev/stdout info;
pid /tmp/nginx.pid;

events {
worker_connections 1024;
Expand All @@ -16,10 +16,16 @@ http {
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;
client_body_temp_path /tmp/client_temp;
proxy_temp_path /tmp/proxy_temp_path;
fastcgi_temp_path /tmp/fastcgi_temp;
uwsgi_temp_path /tmp/uwsgi_temp;
scgi_temp_path /tmp/scgi_temp;
access_log /dev/stdout;


server {
listen 80;
listen 8080;
server_name localhost;
client_max_body_size 32m;

Expand All @@ -29,19 +35,22 @@ http {

root /usr/share/nginx/html/connect;
index index.html;
server_tokens off;

location / {
expires 1s;
try_files $uri /index.html =404;
}

location ~ ^/static {
expires 365d;
expires 365d;
}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /var/lib/nginx/html;
}


}
}
Loading