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

basic docker files #45

Merged
merged 7 commits into from
Nov 8, 2024
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
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
.next
2 changes: 2 additions & 0 deletions .github/workflows/lighthouse.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ jobs:
# Build job
build-and-test:
runs-on: ubuntu-latest
env:
LIGHTHOUSE: 'true'
steps:
- name: Checkout
uses: actions/checkout@v3
Expand Down
31 changes: 31 additions & 0 deletions Dockerfile.prod
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Builder Stage
FROM node:18-alpine AS builder

WORKDIR /app

COPY package*.json ./

RUN npm ci

COPY . .

RUN npm run build

# Production Stage

FROM node:18-alpine AS production

WORKDIR /app

# Copy the built artifacts from the builder stage
COPY --from=builder /app/.next/standalone ./
COPY --from=builder /app/.next/static ./.next/static
COPY --from=builder /app/public ./public
Comment on lines +20 to +23
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍 Looks good! I was inspecting the container's files and I'm not seeing anything I wouldn't expect.
image


# Set the environment variables (if needed)
ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1

EXPOSE 3000

CMD ["node", "server.js"]
6 changes: 3 additions & 3 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ const path = require('path');
* @type {import('next').NextConfig}
*/
const nextConfig = {
output: 'export',
output: process.env.LIGHTHOUSE ? 'export' : 'standalone',
reactStrictMode: true,
swcMinify: true,
images: {
loader: 'custom',
loaderFile: './akamai-loader.js',
},
basePath: '/dibbs-site',
assetPrefix: '/dibbs-site',
basePath: process.env.NODE_ENV === 'production' ? '/dibbs-site' : '',
assetPrefix: process.env.NODE_ENV === 'production' ? '/dibbs-site' : '',
sassOptions: {
includePaths: [
path.join(__dirname, './', 'node_modules', '@uswds', 'uswds', 'packages'),
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
"start": "next start",
"lint": "next lint",
"prepare": "husky",
"fmt": "prettier --write ."
"fmt": "prettier --write .",
"docker-build-prod": "docker build -f Dockerfile.prod -t dibbs-site:prod .",
"docker-run-prod": "docker run -p 3000:3000 dibbs-site:prod"
},
"lint-staged": {
"**/*": "prettier --write --ignore-unknown"
Expand Down
2 changes: 1 addition & 1 deletion src/app/utils/constants.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
const basePath = '/dibbs-site';
const basePath = process.env.NODE_ENV === 'production' ? '/dibbs-site' : '';

export { basePath };
Loading