Skip to content

Commit bb4c9db

Browse files
committed
feat: add dockerfile
1 parent 6a6b985 commit bb4c9db

File tree

4 files changed

+48
-9
lines changed

4 files changed

+48
-9
lines changed

.github/workflows/release.yml

+1-4
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ on:
66
- main
77

88
env:
9-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
10-
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
9+
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}
1110

1211
jobs:
1312
release:
@@ -28,8 +27,6 @@ jobs:
2827
with:
2928
node-version: 20
3029
cache: 'pnpm'
31-
registry-url: "https://npm.pkg.github.com"
32-
scope: "@thecodeorigin"
3330

3431
- name: Install dependencies
3532
run: pnpm install

.npmrc

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
@thecodeorigin:registry=https://npm.pkg.github.com/
21
auto-install-peers=true
32
shamefully-hoist=true
43
package-manager-strict=false

Dockerfile

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Step 1: Base image for building
2+
FROM node:22-bullseye-slim AS build
3+
# Step 2: Set working directory
4+
WORKDIR /app
5+
# Step 3: Install dependencies for pnpm
6+
RUN npm install -g [email protected] # Ensure a specific version of pnpm
7+
# Step 4: Copy application files
8+
COPY .npmrc ./
9+
COPY .nuxtignore ./
10+
COPY package*.json ./
11+
COPY pnpm-*.yaml ./
12+
COPY *.config.ts ./
13+
COPY tsconfig.json ./
14+
COPY package.json package.json
15+
COPY . .
16+
# Step 5: Clean up old node_modules (if any) and install dependencies
17+
RUN rm -rf node_modules && pnpm install
18+
# Step 6: Build the application
19+
RUN pnpm build
20+
# Step 7: Use a smaller image for production
21+
FROM node:22-bullseye-slim AS prod
22+
# Step 8: Set working directory
23+
WORKDIR /app
24+
# Step 9: Install required packages (curl needed for AWS CLI)
25+
RUN apt-get update && apt-get install -y curl unzip
26+
# Step 10: Install pnpm (again) to ensure it's available in the production environment
27+
RUN npm install -g [email protected] # Ensure the same version of pnpm
28+
# Step 11: Copy built application from build stage
29+
COPY --from=build /app /app
30+
# Step 12: Remove unnecessary dev dependencies
31+
RUN pnpm install
32+
# Step 13: Install AWS CLI
33+
RUN curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" \
34+
&& unzip awscliv2.zip \
35+
&& ./aws/install \
36+
&& rm -rf awscliv2.zip aws
37+
# Step 14: Expose port 3000
38+
EXPOSE 3000
39+
# Step 15: Push output files to S3 before starting the application
40+
CMD aws s3 sync /app/.output s3://$AWS_S3_BUCKET
41+
# Step 16: Start the application
42+
CMD ["pnpm", "start"]

package.json

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
22
"name": "@thecodeorigin/nuxt",
33
"type": "module",
4-
"version": "1.9.9",
4+
"version": "1.9.10",
55
"publishConfig": {
6-
"registry": "https://npm.pkg.github.com/",
7-
"access": "restricted"
6+
"registry": "https://registry.npmjs.org",
7+
"access": "public"
88
},
9-
"packageManager": "pnpm@9.12.1",
9+
"packageManager": "pnpm@10.2.1",
1010
"author": "thecodeorigin <[email protected]>",
1111
"homepage": "https://github.com/thecodeorigin/nuxt-template",
1212
"repository": {
@@ -36,6 +36,7 @@
3636
"generate": "nuxt generate",
3737
"preview": "nuxt preview",
3838
"prepare": "jiti ./scripts/prepare.ts",
39+
"start": "node ./.output/server/index.mjs",
3940
"test": "vitest run",
4041
"cleanup": "rimraf .nuxt .output dist node_modules areas",
4142
"stripe:seed": "jiti ./scripts/generate-stripe.ts --esmResolve",

0 commit comments

Comments
 (0)