Skip to content

Commit

Permalink
k8s用のimageを作成するDockerileを作成
Browse files Browse the repository at this point in the history
  • Loading branch information
nose221834 committed Jun 2, 2024
1 parent 955c983 commit 8b4488b
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
37 changes: 37 additions & 0 deletions admin.k8s.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Stage 1: Install dependencies and build the project
FROM node:16-bookworm-slim AS builder
WORKDIR /app

# Copy package.json and package-lock.json (or npm-shrinkwrap.json)
COPY ./admin_view/nuxt-project/package*.json ./

# Install dependencies
RUN npm ci

# Copy Nuxt.js application source code
COPY ./admin_view/nuxt-project/ ./

# Build the application
RUN npm run build

# Stage 2: Serve the app using a Node.js server
FROM node:16-bookworm-slim AS runner
WORKDIR /app

# Copy the built server and client code
COPY --from=builder /app/nuxt.config.js ./nuxt.config.js
COPY --from=builder --chown=nonroot:nonroot /app/.nuxt ./.nuxt
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/package.json ./package.json
COPY --from=builder /app/package-lock.json ./package-lock.json
COPY --from=builder /app/store ./store
COPY --from=builder /app/static ./static
COPY --from=builder /app/assets ./assets
# Set environment variables
ENV NODE_ENV production

# Expose the port the app runs on
EXPOSE 8000

# Start the application
CMD ["node_modules/.bin/nuxt", "start"]
8 changes: 8 additions & 0 deletions api.k8s.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM ruby:2.7.1
WORKDIR /myapp
ENV RAILS_ENV="production"
ENV RAILS_LOG_TO_STDOUT=ON
COPY ./api /myapp
RUN bundle install
CMD ["rails", "server", "-b", "0.0.0.0", "-p", "3000"]
EXPOSE 3000

0 comments on commit 8b4488b

Please sign in to comment.