Skip to content

Commit

Permalink
Build improvements (#808)
Browse files Browse the repository at this point in the history
* Remove about page

* Remove git env vars for production
  • Loading branch information
majakomel authored Oct 21, 2022
1 parent bcd22cc commit 17d901a
Show file tree
Hide file tree
Showing 9 changed files with 134 additions and 182 deletions.
10 changes: 10 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,13 @@ npm-debug.log
package-lock.json
yarn-error.log
ignore
cypress
.github
.editorconfig
.dockerignore
CHANGELOG.md
CODE_OF_CONDUCT.md
cypress.config.js
LICENSE.md
Readme.md
Todo.md
5 changes: 0 additions & 5 deletions .env.production
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,3 @@
NEXT_PUBLIC_OONI_API=https://api.ooni.io
NEXT_PUBLIC_SENTRY_DSN=https://[email protected]/1427510
NEXT_PUBLIC_EXPLORER_URL=https://explorer.ooni.org

RUN_GIT_COMMIT_SHA_SHORT=yarn --silent git:getCommitSHA:short
RUN_GIT_COMMIT_SHA=yarn --silent git:getCommitSHA
RUN_GIT_COMMIT_REF=yarn --silent git:getCommitRef
RUN_GIT_COMMIT_TAGS=yarn --silent git:getReleasesAndTags
29 changes: 13 additions & 16 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,33 +16,30 @@ RUN yarn install --frozen-lockfile
# Rebuild the source code only when needed
FROM node:16.3-alpine3.12 AS builder
WORKDIR /app
COPY . .
COPY --from=deps /app/node_modules ./node_modules
ARG NODE_ENV ${NODE_ENV:-production}
ENV NODE_ENV ${NODE_ENV}
RUN yarn build && yarn install --production --ignore-scripts --prefer-offline
COPY . .
RUN yarn build

# Production image, copy all the files and run next
FROM node:16.3-alpine3.12 AS runner
WORKDIR /app
ARG NODE_ENV ${NODE_ENV:-production}
ENV NODE_ENV ${NODE_ENV}
RUN addgroup -g 1001 -S nodejs
RUN adduser -S nextjs -u 1001
ENV NODE_ENV production
ENV NEXT_TELEMETRY_DISABLED 1
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs

# You only need to copy next.config.js if you are NOT using the default configuration
COPY --from=builder /app/next.config.js ./
COPY --from=builder /app/public ./public
COPY --from=builder --chown=nextjs:nodejs /app/.next ./.next
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/package.json ./package.json

# Automatically leverage output traces to reduce image size
# https://nextjs.org/docs/advanced-features/output-file-tracing
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static

USER nextjs

EXPOSE 3100
ENV PORT 3100

ARG NODE_ENV ${NODE_ENV:-production}
ENV NODE_ENV ${NODE_ENV}
ENV NEXT_TELEMETRY_DISABLED 1

CMD ["yarn", "start"]
CMD ["node", "server.js"]
9 changes: 5 additions & 4 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const SentryWebpackPluginOptions = {
}

module.exports = withSentryConfig({
output: 'standalone',
async redirects() {
return [
{
Expand All @@ -25,10 +26,10 @@ module.exports = withSentryConfig({
},

webpack: (config, options) => {
const gitCommitSHAShort = execSync(process.env.RUN_GIT_COMMIT_SHA_SHORT)
const gitCommitSHA = execSync(process.env.RUN_GIT_COMMIT_SHA)
const gitCommitRef = execSync(process.env.RUN_GIT_COMMIT_REF)
const gitCommitTags = execSync(process.env.RUN_GIT_COMMIT_TAGS)
const gitCommitSHAShort = process.env.RUN_GIT_COMMIT_SHA_SHORT ? execSync(process.env.RUN_GIT_COMMIT_SHA_SHORT) : ''
const gitCommitSHA = process.env.RUN_GIT_COMMIT_SHA ? execSync(process.env.RUN_GIT_COMMIT_SHA) : ''
const gitCommitRef = process.env.RUN_GIT_COMMIT_REF ? execSync(process.env.RUN_GIT_COMMIT_REF) : ''
const gitCommitTags = process.env.RUN_GIT_COMMIT_TAGS ? execSync(process.env.RUN_GIT_COMMIT_TAGS) : ''

config.plugins.push(
new options.webpack.DefinePlugin({
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"fontsource-fira-sans": "^4.0.0",
"lodash.debounce": "^4.0.8",
"markdown-to-jsx": "^7.1.7",
"next": "12.2.5",
"next": "^12.3.1",
"nprogress": "^0.2.0",
"ooni-components": "^0.4.7",
"pretty-ms": "^8.0.0",
Expand Down
4 changes: 3 additions & 1 deletion pages/404.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import Layout from '../components/Layout'
import NavBar from '../components/NavBar'
import OONI404 from '../public/static/images/OONI_404.svg'

export default function Custom404() {
const Custom404 = () => {
const router = useRouter()
return (
<Layout>
Expand Down Expand Up @@ -61,3 +61,5 @@ export default function Custom404() {
</Layout>
)
}

export default Custom404
32 changes: 0 additions & 32 deletions pages/about.js

This file was deleted.

21 changes: 0 additions & 21 deletions pages/experimental/index.js

This file was deleted.

Loading

1 comment on commit 17d901a

@vercel
Copy link

@vercel vercel bot commented on 17d901a Oct 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

explorer – ./

explorer-git-master-ooni1.vercel.app
explorer-ooni1.vercel.app
explorer-one.vercel.app

Please sign in to comment.