Skip to content

Commit

Permalink
feat: setup docker to run tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JayanaGunaweera01 committed Mar 13, 2024
1 parent 64b35c8 commit d2509a8
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 0 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -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
23 changes: 23 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
7 changes: 7 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: "3.6"

services:
chatgpt:
build: .
ports:
- 3000:3000

0 comments on commit d2509a8

Please sign in to comment.