From 8b4488ba29f9f144a3c182677824cf4da5d530af Mon Sep 17 00:00:00 2001 From: nose221834 Date: Sun, 2 Jun 2024 16:26:56 +0900 Subject: [PATCH] =?UTF-8?q?k8s=E7=94=A8=E3=81=AEimage=E3=82=92=E4=BD=9C?= =?UTF-8?q?=E6=88=90=E3=81=99=E3=82=8BDockerile=E3=82=92=E4=BD=9C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin.k8s.Dockerfile | 37 +++++++++++++++++++++++++++++++++++++ api.k8s.Dockerfile | 8 ++++++++ 2 files changed, 45 insertions(+) create mode 100644 admin.k8s.Dockerfile create mode 100644 api.k8s.Dockerfile diff --git a/admin.k8s.Dockerfile b/admin.k8s.Dockerfile new file mode 100644 index 000000000..dce4458a4 --- /dev/null +++ b/admin.k8s.Dockerfile @@ -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"] diff --git a/api.k8s.Dockerfile b/api.k8s.Dockerfile new file mode 100644 index 000000000..54068c179 --- /dev/null +++ b/api.k8s.Dockerfile @@ -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 \ No newline at end of file