diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml new file mode 100644 index 0000000..863a391 --- /dev/null +++ b/.github/workflows/docker-image.yml @@ -0,0 +1,24 @@ +name: tests + +on: + push: + branches: ["main"] + pull_request: + branches: ["main"] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Setup Docker + uses: docker/setup-buildx-action@v1 + + - name: Build Docker image + run: docker build -t my-nextjs-app -f Dockerfile . + + - name: Run Docker container + run: docker run -d --name nextjs-container -p 3000:3000 my-nextjs-app \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..f717173 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,23 @@ +# Use the official Node.js image as a base image +FROM node:20 + +# Set the working directory +WORKDIR /app + +# Copy package.json and yarn.lock into the working directory +COPY package.json yarn.lock ./ + +# Install dependencies +RUN yarn install --frozen-lockfile + +# Copy the source code and other necessary files/directories +COPY . . + +# Build the Next.js app +RUN yarn build + +# Expose the port the app runs on +EXPOSE 3000 + +# Start the app +CMD ["yarn", "start"] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..fe97a05 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,7 @@ +version: "3.6" + +services: + chatgpt: + build: . + ports: + - 3000:3000 \ No newline at end of file