update Dockerfile

This commit is contained in:
Dawid Wysokiński 2021-11-04 17:40:19 +01:00
parent 06801d28a9
commit a5682b0897
Signed by: Kichiyaki
GPG Key ID: EF14026D247EB867
3 changed files with 28 additions and 15 deletions

View File

@ -1,4 +1,3 @@
GA_TRACKING_ID=G-355ES1R23J
NEXT_PUBLIC_API_URI=https://api.zdamegzaminzawodowy.pl/graphql
NEXT_PUBLIC_URL=https://zdamegzaminzawodowy.pl
NEXT_PUBLIC_CDN_URI=https://cdn.zdamegzaminzawodowy.pl/

View File

@ -8,28 +8,42 @@ RUN yarn install --frozen-lockfile
# Rebuild the source code only when needed
FROM node:14.18.1-alpine AS builder
ARG ENABLE_SENTRY_WEBPACK_PLUGIN="false"
ARG SENTRY_URL=""
ARG SENTRY_ORG=""
ARG SENTRY_PROJECT=""
ARG SENTRY_AUTH_TOKEN=""
ARG SENTRY_DSN=""
WORKDIR /app
ENV ENABLE_SENTRY_WEBPACK_PLUGIN=$ENABLE_SENTRY_WEBPACK_PLUGIN \
SENTRY_URL=$SENTRY_URL \
SENTRY_ORG=$SENTRY_ORG \
SENTRY_PROJECT=$SENTRY_PROJECT \
SENTRY_AUTH_TOKEN=$SENTRY_AUTH_TOKEN \
SENTRY_DSN=$SENTRY_DSN \
NEXT_PUBLIC_SENTRY_DSN=$SENTRY_DSN \
BUILDING_PROCESS=true
COPY . .
COPY --from=deps /app/node_modules ./node_modules
RUN yarn build
# Production image, copy all the files and run next
FROM node:14.18.1-alpine AS runner
WORKDIR /app
ENV NODE_ENV=production
ENV BUILDING_PROCESS=false
ARG SENTRY_DSN=""
ENV NODE_ENV=production \
SENTRY_DSN=$SENTRY_DSN \
NEXT_PUBLIC_SENTRY_DSN=$SENTRY_DSN \
BUILDING_PROCESS=false
COPY --from=builder /app/next.config.js ./
COPY --from=builder /app/public ./public
COPY --from=builder /app/.next ./.next

View File

@ -1,6 +1,7 @@
import { GetServerSideProps } from 'next';
import { gql } from 'graphql-request';
import { getServerSideSitemap } from 'next-sitemap';
import * as Sentry from '@sentry/nextjs';
import { ISitemapField } from 'next-sitemap/dist/@types/interface';
import { createClient } from 'libs/graphql';
import { Query, QueryQualificationsArgs } from 'libs/graphql';
@ -33,23 +34,22 @@ export const getServerSideProps: GetServerSideProps = async ctx => {
if (Array.isArray(items)) {
fields = ([] as typeof fields).concat(
...QUESTIONS.map(limit => {
return items.map(
(item): ISitemapField => {
return {
loc: `${WEBSITE_URL}${resolveAs({
pathname: Route.TestPage,
query: { slug: item.slug, limit },
})}`,
lastmod: new Date().toISOString(),
changefreq: 'always',
};
}
);
return items.map((item): ISitemapField => {
return {
loc: `${WEBSITE_URL}${resolveAs({
pathname: Route.TestPage,
query: { slug: item.slug, limit },
})}`,
lastmod: new Date().toISOString(),
changefreq: 'always',
};
});
})
);
}
} catch (e) {
console.log('server-sitemap.xml', e.message);
Sentry.captureException(e);
}
return getServerSideSitemap(ctx, fields);