Skip to content

Commit

Permalink
Merge pull request #18 from luojiyin1987/docker-deployment
Browse files Browse the repository at this point in the history
Docker deployment
  • Loading branch information
KoriIku authored Oct 10, 2024
2 parents 973145f + 1b73316 commit 6962a33
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 18 deletions.
49 changes: 49 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Node modules
node_modules

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

# Build output
dist
dist-ssr

# # Local env files
# .env
# .env.*
# !.env.example


# Testing
coverage

# Misc
*.local

# Version control
.git
.gitignore

# Docker
Dockerfile
.dockerignore

# Temporary files
*.tmp
*.temp
19 changes: 4 additions & 15 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,19 @@
on:
push:
branches: [ main ]
branches: [main]
pull_request:
branches: [ main ]
branches: [main]
env:
IMAGE_NAME: luxirty-search
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
name: Install pnpm
with:
version: 9
run_install: false
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'pnpm'
- run: pnpm install && pnpm build


- name: Set up QEMU for multi-architecture builds
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

Expand Down
19 changes: 16 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
FROM nginx:1.27
FROM node:20-slim AS base

ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable
COPY . /app
WORKDIR /app

FROM base AS build
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm i --frozen-lockfile
RUN pnpm build

# Production stage
FROM nginx:stable-alpine as production-stage
COPY ./conf/nginx.conf /etc/nginx/conf.d/default.conf
COPY ./dist/ /usr/share/nginx/html
COPY --from=build /app/dist /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
CMD ["nginx", "-g", "daemon off;"]

0 comments on commit 6962a33

Please sign in to comment.