From 9193645586c1f7be6bca7b321b4b1d219443ee06 Mon Sep 17 00:00:00 2001 From: spksoft Date: Mon, 1 May 2023 16:12:37 +0700 Subject: [PATCH 1/4] chore: add docker-compose --- .gitignore | 3 +++ api/Dockerfile | 20 ++++++++++++++++++++ docker-compose.prod.yml | 16 ++++++++++++++++ frontend-app/Dockerfile | 28 ++++++++++++++++++++++++++++ 4 files changed, 67 insertions(+) create mode 100644 api/Dockerfile create mode 100644 docker-compose.prod.yml create mode 100644 frontend-app/Dockerfile diff --git a/.gitignore b/.gitignore index 400bc4c..85f09d1 100644 --- a/.gitignore +++ b/.gitignore @@ -104,3 +104,6 @@ dist # TernJS port file .tern-port + +api_data_tmp/ +api_data_upload/ \ No newline at end of file diff --git a/api/Dockerfile b/api/Dockerfile new file mode 100644 index 0000000..0e2d296 --- /dev/null +++ b/api/Dockerfile @@ -0,0 +1,20 @@ +# Set the base image to use for this Docker image +FROM node:14.16.0-alpine + +# Set the working directory for the Docker image +WORKDIR /app + +# Copy the package.json and package-lock.json files into the Docker image +COPY package*.json ./ + +# Install the dependencies in the Docker image +RUN npm install + +# Copy the rest of the application files into the Docker image +COPY . . + +# Set the port that the Docker image will use +EXPOSE 1337 + +# Start the Strapi server when the Docker image runs +CMD ["npm", "start"] diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml new file mode 100644 index 0000000..ba151ef --- /dev/null +++ b/docker-compose.prod.yml @@ -0,0 +1,16 @@ +version: "3" + +services: + strapi: + build: + context: ./api + ports: + - "1337:1337" + volumes: + - ./api_data_upload:/app/public/uploads + - ./api_data_tmp:/app/.tmp + nextjs: + build: + context: ./frontend-app + ports: + - "3000:3000" diff --git a/frontend-app/Dockerfile b/frontend-app/Dockerfile new file mode 100644 index 0000000..d0b4f58 --- /dev/null +++ b/frontend-app/Dockerfile @@ -0,0 +1,28 @@ +# Base image +FROM node:16-alpine + +# Set working directory +WORKDIR /app + +# Copy package.json and package-lock.json +COPY package*.json ./ + +# Install dependencies +RUN npm install --production + +# Copy application files +COPY . . + +# Build Next.js application +RUN npm run build + +# Set environment variables +ENV NODE_ENV production +ENV PORT 3000 +ENV NEXT_PUBLIC_API_BASE_URL http://localhost:1337 + +# Expose port +EXPOSE 3000 + +# Start server +CMD ["npm", "start"] \ No newline at end of file From bdab8e499d5d2f67e2ff1eb3f194ed13fd9378a0 Mon Sep 17 00:00:00 2001 From: spksoft Date: Mon, 1 May 2023 16:42:42 +0700 Subject: [PATCH 2/4] chore: add test --- .github/workflows/test.yml | 27 +++++++++++++++++++++++++++ docker-compose.staging.yml | 0 2 files changed, 27 insertions(+) create mode 100644 .github/workflows/test.yml create mode 100644 docker-compose.staging.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..c4d7950 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,27 @@ +name: Test PR + +on: + pull_request: + branches: + - main + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Install Dependencies + run: | + cd api + npm install + cd .. + cd frontend-app + npm install + - name: Run Tests + run: | + cd api + npm test + cd .. + cd frontend-app + npm test \ No newline at end of file diff --git a/docker-compose.staging.yml b/docker-compose.staging.yml new file mode 100644 index 0000000..e69de29 From a8590c0315e13136b2c305cd75c4da4626a966e6 Mon Sep 17 00:00:00 2001 From: spksoft Date: Mon, 1 May 2023 16:50:17 +0700 Subject: [PATCH 3/4] chore: add test script --- api/package.json | 3 ++- frontend-app/package.json | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/api/package.json b/api/package.json index 892bf2b..5557d87 100644 --- a/api/package.json +++ b/api/package.json @@ -7,7 +7,8 @@ "develop": "strapi develop", "start": "strapi start", "build": "strapi build", - "strapi": "strapi" + "strapi": "strapi", + "test": "echo \"No test specified\" && exit 0" }, "dependencies": { "@strapi/plugin-i18n": "4.3.8", diff --git a/frontend-app/package.json b/frontend-app/package.json index 096a839..119dca0 100644 --- a/frontend-app/package.json +++ b/frontend-app/package.json @@ -10,7 +10,8 @@ "dev": "next dev", "build": "next build", "start": "next start", - "lint": "next lint" + "lint": "next lint", + "test": "echo \"No test specified\" && exit 0" }, "dependencies": { "axios": "^0.27.2", From 85ac4a16378a59e230f1ba5eedcd1ed587d93859 Mon Sep 17 00:00:00 2001 From: spksoft Date: Wed, 3 May 2023 13:38:03 +0700 Subject: [PATCH 4/4] fix dockerfile --- frontend-app/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend-app/Dockerfile b/frontend-app/Dockerfile index d0b4f58..36dc0d7 100644 --- a/frontend-app/Dockerfile +++ b/frontend-app/Dockerfile @@ -8,7 +8,7 @@ WORKDIR /app COPY package*.json ./ # Install dependencies -RUN npm install --production +RUN npm install # Copy application files COPY . .