Skip to content

Commit 3f2dbd1

Browse files
authored
Merge pull request #51 from CreoWis/issue-43-add-dockerfile
Add Docker Support for the Application
2 parents bafe64d + 8917019 commit 3f2dbd1

File tree

5 files changed

+94
-6
lines changed

5 files changed

+94
-6
lines changed

.dockerignore

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Include any files or directories that you don't want to be copied to your
2+
# container here (e.g., local build artifacts, temporary files, etc.).
3+
#
4+
# For more help, visit the .dockerignore file reference guide at
5+
# https://docs.docker.com/go/build-context-dockerignore/
6+
7+
**/.classpath
8+
**/.dockerignore
9+
**/.git
10+
**/.gitignore
11+
**/.project
12+
**/.settings
13+
**/.toolstarget
14+
**/.vs
15+
**/.vscode
16+
**/.next
17+
**/.cache
18+
**/*.*proj.user
19+
**/*.dbmdl
20+
**/*.jfm
21+
**/charts
22+
**/docker-compose*
23+
**/compose*
24+
**/Dockerfile*
25+
**/node_modules
26+
**/npm-debug.log
27+
**/obj
28+
**/secrets.dev.yaml
29+
**/values.dev.yaml
30+
**/build
31+
**/dist
32+
LICENSE
33+
README.md

Dockerfile

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
FROM --platform=linux/arm64/v8 node:18-alpine AS build
2+
# Install dependencies only when needed
3+
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
4+
RUN apk add --no-cache libc6-compat
5+
WORKDIR /app
6+
7+
8+
COPY package.json package-lock.json ./
9+
RUN npm ci
10+
COPY . .
11+
RUN npm run build
12+
13+
14+
# Build Stage
15+
FROM --platform=linux/arm64/v8 node:18-alpine AS build-stage
16+
RUN apk update && apk upgrade && apk add dumb-init && adduser -D nextuser
17+
18+
19+
20+
WORKDIR /app
21+
COPY --from=build --chown=nextuser:nextuser /app/public ./public
22+
COPY --from=build --chown=nextuser:nextuser /app/.next/standalone ./
23+
COPY --from=build --chown=nextuser:nextuser /app/.next/static ./.next/static
24+
25+
USER nextuser
26+
27+
EXPOSE 3000
28+
29+
ENV HOST=0.0.0.0 PORT=3000
30+
CMD ["dumb-init","node","server.js"]

README.md

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,26 @@ Say goodbye to setup headaches and hello to consistent code quality. Elevate you
3636
- **Prettier Plugin Tailwindcss**: Automatic sorting of tailwind classnames using the official prettier plugin.
3737
- **Prettier Plugin Sort Imports**: Organize import declarations alphabetically within groups, which can help improve readability when working on larger projects.
3838
- **Husky**: Ensure code quality and prevent bad commits with pre-commit hooks powered by Husky.
39+
- **Docker Support**: Complete Docker configuration.
40+
```bash
41+
- Start the application using this Docker command:
42+
43+
docker-compose up
44+
45+
The command will:
46+
1. Build the application container
47+
2. Install all dependencies
48+
3. Start the development server
49+
4. Make the application available on localhost
50+
```
51+
3952
- **Internationalization (i18n)**: Built-in support for multiple languages using next-intl, making it easy to create multilingual applications with locale-specific routing and translations.
53+
## Getting Started
54+
> Usage
55+
56+
```bash
57+
npx create-next-app -e https://github.com/CreoWis/next-js-launchpad
58+
```
4059

4160
## Internationalization (i18n)
4261
NextJsLaunchpad comes with built-in internationalization support using next-intl. This integration provides:
@@ -92,12 +111,6 @@ To use strings from a language file in both **client and server** components, us
92111
<h1>{t('welcomeMessage')}</h1>
93112
```
94113
95-
## Getting Started
96-
> Usage
97-
98-
```bash
99-
npx create-next-app -e https://github.com/CreoWis/next-js-launchpad
100-
```
101114
102115
<!-- Project should be public for the above command to work -->
103116

docker-compose.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
version: "3.8"
2+
3+
services:
4+
demo-app-name:
5+
build:
6+
context: . # Path to the directory containing the Dockerfile
7+
dockerfile: Dockerfile # Name of the Dockerfile (if not named "Dockerfile", specify it here)
8+
# env_file:
9+
# - .env
10+
ports:
11+
- "3000:3000" # Expose port 3000 on the host, mapping to port 3000 in the container

next.config.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import createNextIntlPlugin from 'next-intl/plugin';
44
const withNextIntl = createNextIntlPlugin();
55

66
const nextConfig = {
7+
output: 'standalone',
78
reactStrictMode: true,
89
swcMinify: true,
910
productionBrowserSourceMaps: true,

0 commit comments

Comments
 (0)