From f2f1473f00aebbf28f091b232780aab3f6703209 Mon Sep 17 00:00:00 2001 From: Kittipod Lambangchang Date: Fri, 6 Sep 2024 01:43:02 +0700 Subject: [PATCH 1/2] feat: setup docker --- .dockerignore | 14 ++++++++++++++ Dockerfile | 40 ++++++++++++++++++++++++++++++++++++++++ docker-compose.yml | 9 +++++++++ next.config.mjs | 4 +++- 4 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..a363177 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,14 @@ +.git +node_modules +docker-compose.yml +Dockerfile +.prettierrc +.prettierignore +.gitignore +.eslintrc.js +README.md +.husky +.github +.next +!.next/static +!.next/standalone \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..8c8db99 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,40 @@ +FROM node:20-alpine As base + +ENV PNPM_HOME="/pnpm" +ENV PATH="$PNPM_HOME:$PATH" + +RUN corepack enable + +WORKDIR /usr/app + +FROM base As deps + +COPY package.json pnpm-lock.yaml ./ + +RUN --mount=type=cache,id=pnpm-store,target=/pnpm/store pnpm install --frozen-lockfile + +FROM base As builder + +COPY --from=deps --chown=nextjs:nodejs /usr/app/node_modules ./node_modules +COPY . . + +RUN pnpm run build + +FROM node:20-alpine As runner + +WORKDIR /usr/app + +RUN addgroup --system --gid 1001 nodejs +RUN adduser --system --uid 1001 nextjs +RUN mkdir .next +RUN chown nextjs:nodejs .next + +USER nextjs + +COPY --chown=nextjs:nodejs --from=builder /usr/app/node_modules ./node_modules +COPY --chown=nextjs:nodejs --from=builder /usr/app/.next/standalone ./ +COPY --chown=nextjs:nodejs --from=builder /usr/app/.next/static ./.next/static + +EXPOSE 3000 + +CMD [ "node", "server.js" ] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..df0ba40 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,9 @@ +services: + reg_helper: + container_name: reg_helper + build: + context: . + dockerfile: Dockerfile + restart: always + ports: + - 3000:3000 diff --git a/next.config.mjs b/next.config.mjs index 4678774..aed5ac3 100644 --- a/next.config.mjs +++ b/next.config.mjs @@ -1,4 +1,6 @@ /** @type {import('next').NextConfig} */ -const nextConfig = {}; +const nextConfig = { + output: 'standalone' +}; export default nextConfig; From ab37ef6f3b5bb07889e7ed4c791cea14d4595a33 Mon Sep 17 00:00:00 2001 From: Kittipod Lambangchang Date: Fri, 6 Sep 2024 01:50:41 +0700 Subject: [PATCH 2/2] fix: fix pnpm-lock.yml not match with package.json --- pnpm-lock.yaml | 54 -------------------------------------------------- 1 file changed, 54 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 7b6fe02..9e7fe5b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -42,9 +42,6 @@ importers: eslint-config-prettier: specifier: ^9.1.0 version: 9.1.0(eslint@8.57.0) - eslint-plugin-prettier: - specifier: ^5.2.1 - version: 5.2.1(eslint-config-prettier@9.1.0(eslint@8.57.0))(eslint@8.57.0)(prettier@3.3.3) eslint-plugin-unused-imports: specifier: ^4.1.3 version: 4.1.3(@typescript-eslint/eslint-plugin@8.4.0(@typescript-eslint/parser@8.4.0(eslint@8.57.0)(typescript@5.5.4))(eslint@8.57.0)(typescript@5.5.4))(eslint@8.57.0) @@ -209,10 +206,6 @@ packages: resolution: {integrity: sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==} engines: {node: '>=14'} - '@pkgr/core@0.1.1': - resolution: {integrity: sha512-cq8o4cWH0ibXh9VGi5P20Tu9XF/0fFXl9EUinr9QfTM7a7p0oTA4iJRCQWppXR1Pg8dSM0UCItCkPwsk9qWWYA==} - engines: {node: ^12.20.0 || ^14.18.0 || >=16.0.0} - '@rtsao/scc@1.1.0': resolution: {integrity: sha512-zt6OdqaDoOnJ1ZYsCYGt9YmWzDXl4vQdKTyJev62gFhRGKdx7mcT54V9KIjg+d2wi9EXsPvAPKe7i7WjfVWB8g==} @@ -747,20 +740,6 @@ packages: peerDependencies: eslint: ^3 || ^4 || ^5 || ^6 || ^7 || ^8 || ^9 - eslint-plugin-prettier@5.2.1: - resolution: {integrity: sha512-gH3iR3g4JfF+yYPaJYkN7jEl9QbweL/YfkoRlNnuIEHEz1vHVlCmWOS+eGGiRuzHQXdJFCOTxRgvju9b8VUmrw==} - engines: {node: ^14.18.0 || >=16.0.0} - peerDependencies: - '@types/eslint': '>=8.0.0' - eslint: '>=8.0.0' - eslint-config-prettier: '*' - prettier: '>=3.0.0' - peerDependenciesMeta: - '@types/eslint': - optional: true - eslint-config-prettier: - optional: true - eslint-plugin-react-hooks@4.6.2: resolution: {integrity: sha512-QzliNJq4GinDBcD8gPB5v0wh6g8q3SUi6EFF0x8N/BL9PoVs0atuGc47ozMRyOWAKdwaZ5OnbOEa3WR+dSGKuQ==} engines: {node: '>=10'} @@ -825,9 +804,6 @@ packages: fast-deep-equal@3.1.3: resolution: {integrity: sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==} - fast-diff@1.3.0: - resolution: {integrity: sha512-VxPP4NqbUjj6MaAOafWeUn2cXWLcCtljklUtZf0Ind4XQ+QPtmA0b18zZy0jIQx+ExRVCR/ZQpBmik5lXshNsw==} - fast-glob@3.3.2: resolution: {integrity: sha512-oX2ruAFQwf/Orj8m737Y5adxDQO0LAB7/S5MnxCdTNDd4p6BsyIVsv9JQsATbTSq8KHRpLwIHbVlUNatxd+1Ow==} engines: {node: '>=8.6.0'} @@ -1478,10 +1454,6 @@ packages: resolution: {integrity: sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==} engines: {node: '>= 0.8.0'} - prettier-linter-helpers@1.0.0: - resolution: {integrity: sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w==} - engines: {node: '>=6.0.0'} - prettier-plugin-tailwindcss@0.6.6: resolution: {integrity: sha512-OPva5S7WAsPLEsOuOWXATi13QrCKACCiIonFgIR6V4lYv4QLp++UXVhZSzRbZxXGimkQtQT86CC6fQqTOybGng==} engines: {node: '>=14.21.3'} @@ -1764,10 +1736,6 @@ packages: resolution: {integrity: sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==} engines: {node: '>= 0.4'} - synckit@0.9.1: - resolution: {integrity: sha512-7gr8p9TQP6RAHusBOSLs46F4564ZrjV8xFmw5zCmgmhGUcw2hxsShhJ6CEiHQMgPDwAQ1fWHPM0ypc4RMAig4A==} - engines: {node: ^14.18.0 || >=16.0.0} - tailwindcss@3.4.10: resolution: {integrity: sha512-KWZkVPm7yJRhdu4SRSl9d4AK2wM3a50UsvgHZO7xY77NQr2V+fIrEuoDGQcbvswWvFGbS2f6e+jC/6WJm1Dl0w==} engines: {node: '>=14.0.0'} @@ -2010,8 +1978,6 @@ snapshots: '@pkgjs/parseargs@0.11.0': optional: true - '@pkgr/core@0.1.1': {} - '@rtsao/scc@1.1.0': {} '@rushstack/eslint-patch@1.10.4': {} @@ -2741,15 +2707,6 @@ snapshots: safe-regex-test: 1.0.3 string.prototype.includes: 2.0.0 - eslint-plugin-prettier@5.2.1(eslint-config-prettier@9.1.0(eslint@8.57.0))(eslint@8.57.0)(prettier@3.3.3): - dependencies: - eslint: 8.57.0 - prettier: 3.3.3 - prettier-linter-helpers: 1.0.0 - synckit: 0.9.1 - optionalDependencies: - eslint-config-prettier: 9.1.0(eslint@8.57.0) - eslint-plugin-react-hooks@4.6.2(eslint@8.57.0): dependencies: eslint: 8.57.0 @@ -2866,8 +2823,6 @@ snapshots: fast-deep-equal@3.1.3: {} - fast-diff@1.3.0: {} - fast-glob@3.3.2: dependencies: '@nodelib/fs.stat': 2.0.5 @@ -3515,10 +3470,6 @@ snapshots: prelude-ls@1.2.1: {} - prettier-linter-helpers@1.0.0: - dependencies: - fast-diff: 1.3.0 - prettier-plugin-tailwindcss@0.6.6(prettier@3.3.3): dependencies: prettier: 3.3.3 @@ -3776,11 +3727,6 @@ snapshots: supports-preserve-symlinks-flag@1.0.0: {} - synckit@0.9.1: - dependencies: - '@pkgr/core': 0.1.1 - tslib: 2.7.0 - tailwindcss@3.4.10: dependencies: '@alloc/quick-lru': 5.2.0