From f0889fb800f99af1e2766003829a2116c23d2168 Mon Sep 17 00:00:00 2001 From: Justus Kluge Date: Thu, 3 Apr 2025 14:32:12 +0200 Subject: [PATCH 01/11] Initial Dockerfiles --- .dockerignore | 3 +++ Dockerfile | 9 +++++++++ 2 files changed, 12 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..37499860 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,3 @@ +.git +node_modules +.env diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..74fc08ea --- /dev/null +++ b/Dockerfile @@ -0,0 +1,9 @@ +# use an existing image +FROM node:18-alpine +WORKDIR /app +COPY my-app . +RUN npm install --production +RUN npm install react +EXPOSE 5173 + +CMD ["npm", "run", "dev"] From 628d98387c19ba23ab75c7ff4bd2d8361bb9a3ec Mon Sep 17 00:00:00 2001 From: Justus Kluge Date: Thu, 3 Apr 2025 14:55:04 +0200 Subject: [PATCH 02/11] Docker Setup finalized --- Dockerfile | 4 +--- docker-compose.yml | 15 +++++++++++++++ my-app/vite.config.js | 4 ++++ 3 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 docker-compose.yml diff --git a/Dockerfile b/Dockerfile index 74fc08ea..e66aa84e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,8 +2,6 @@ FROM node:18-alpine WORKDIR /app COPY my-app . -RUN npm install --production -RUN npm install react +RUN if [ "$NODE_ENV" = "production" ]; then npm install --production; else npm install; fi EXPOSE 5173 - CMD ["npm", "run", "dev"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..6da3f2d9 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,15 @@ +services: + app: + build: + context: . + dockerfile: Dockerfile + container_name: my-react-app + ports: + - "5173:5173" + volumes: + - ./my-app:/app # Mount local 'my-app' folder to /app inside the container + environment: + - NODE_ENV=development # Set environment variable to development + command: npm run dev # Command to run in the container + stdin_open: true # Allows interactive sessions + tty: true # Keeps the container running interactively \ No newline at end of file diff --git a/my-app/vite.config.js b/my-app/vite.config.js index 9b51b3f4..5af001e8 100644 --- a/my-app/vite.config.js +++ b/my-app/vite.config.js @@ -6,4 +6,8 @@ export default defineConfig({ plugins: [react(), tailwindcss(), ], + server: { + host: '0.0.0.0', // Allow external access + port: 5173, // Ensure the port is 5173 (or change if needed) + } }) From 7160b99f7d42e47553ed9b2bb148823aabb1077b Mon Sep 17 00:00:00 2001 From: Justus Kluge Date: Thu, 3 Apr 2025 14:57:54 +0200 Subject: [PATCH 03/11] Remove some comments --- Dockerfile | 1 - docker-compose.yml | 10 +++++----- my-app/vite.config.js | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index e66aa84e..6f88e1d2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,3 @@ -# use an existing image FROM node:18-alpine WORKDIR /app COPY my-app . diff --git a/docker-compose.yml b/docker-compose.yml index 6da3f2d9..dd18e954 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,9 +7,9 @@ services: ports: - "5173:5173" volumes: - - ./my-app:/app # Mount local 'my-app' folder to /app inside the container + - ./my-app:/app # mount local 'my-app' to /app inside the container environment: - - NODE_ENV=development # Set environment variable to development - command: npm run dev # Command to run in the container - stdin_open: true # Allows interactive sessions - tty: true # Keeps the container running interactively \ No newline at end of file + - NODE_ENV=development # set environment variable to development + command: npm run dev + stdin_open: true # interactive sessions + tty: true # keep the container running interactively \ No newline at end of file diff --git a/my-app/vite.config.js b/my-app/vite.config.js index 5af001e8..d476f23a 100644 --- a/my-app/vite.config.js +++ b/my-app/vite.config.js @@ -8,6 +8,6 @@ export default defineConfig({ ], server: { host: '0.0.0.0', // Allow external access - port: 5173, // Ensure the port is 5173 (or change if needed) + port: 5173, } }) From 7e75958913554618e588c2e37103e34a326ea9ab Mon Sep 17 00:00:00 2001 From: Justus Kluge Date: Thu, 3 Apr 2025 15:27:11 +0200 Subject: [PATCH 04/11] Wrong app name --- docker-compose.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index dd18e954..cfef351f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,7 +3,7 @@ services: build: context: . dockerfile: Dockerfile - container_name: my-react-app + container_name: my-app ports: - "5173:5173" volumes: @@ -12,4 +12,4 @@ services: - NODE_ENV=development # set environment variable to development command: npm run dev stdin_open: true # interactive sessions - tty: true # keep the container running interactively \ No newline at end of file + tty: true # keep the container running interactively From a2aa14a6193836bfd3d519af49894ba1489d1f69 Mon Sep 17 00:00:00 2001 From: Kacper Lisik Date: Thu, 3 Apr 2025 15:53:40 +0200 Subject: [PATCH 05/11] Small changes xD --- Dockerfile | 2 +- docker-compose.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 6f88e1d2..d51a9e57 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ FROM node:18-alpine WORKDIR /app COPY my-app . -RUN if [ "$NODE_ENV" = "production" ]; then npm install --production; else npm install; fi +RUN if [ "$NODE_ENV" = "production" ]; then npm install --production; else npm ci; fi EXPOSE 5173 CMD ["npm", "run", "dev"] diff --git a/docker-compose.yml b/docker-compose.yml index dd18e954..01feb0e5 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,7 +3,7 @@ services: build: context: . dockerfile: Dockerfile - container_name: my-react-app + container_name: my-app ports: - "5173:5173" volumes: From bc3c149b1719a2109cc4442ac26c203e10a1ed03 Mon Sep 17 00:00:00 2001 From: jkluge <92872894+jkluge@users.noreply.github.com> Date: Thu, 3 Apr 2025 15:56:22 +0200 Subject: [PATCH 06/11] Update .dockerignore --- .dockerignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.dockerignore b/.dockerignore index 37499860..7ca82aad 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,3 +1,4 @@ .git node_modules +dist .env From ea550b6d1d53ff7e3fee0e0950e8dc0ca05c59e7 Mon Sep 17 00:00:00 2001 From: Justus Kluge Date: Thu, 3 Apr 2025 15:58:45 +0200 Subject: [PATCH 07/11] Always do npm ci --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index d51a9e57..c6e71bb3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ FROM node:18-alpine WORKDIR /app COPY my-app . -RUN if [ "$NODE_ENV" = "production" ]; then npm install --production; else npm ci; fi +RUN npm ci EXPOSE 5173 CMD ["npm", "run", "dev"] From a402742b249baebe64df842f2fd9b64480611b66 Mon Sep 17 00:00:00 2001 From: Justus Kluge Date: Thu, 3 Apr 2025 16:59:39 +0200 Subject: [PATCH 08/11] Updated docker --- Dockerfile | 2 ++ docker-compose.yml | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index c6e71bb3..d7c6cc26 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,5 +2,7 @@ FROM node:18-alpine WORKDIR /app COPY my-app . RUN npm ci +ARG CI=false +RUN if [ "$CI" = "true" ]; then npm run build; fi EXPOSE 5173 CMD ["npm", "run", "dev"] diff --git a/docker-compose.yml b/docker-compose.yml index cfef351f..731c689d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,7 +2,9 @@ services: app: build: context: . - dockerfile: Dockerfile + dockerfile: Dockerfile + args: + - CI=${CI:-false} container_name: my-app ports: - "5173:5173" From 64c5c05d4ab0f717ef02a551073cc1d15c9146df Mon Sep 17 00:00:00 2001 From: Justus Kluge Date: Wed, 16 Apr 2025 13:24:15 +0200 Subject: [PATCH 09/11] Updated Docker Images --- .github/workflows/docker-build.yml | 2 +- .github/workflows/docker-image.yml | 2 +- Dockerfile | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index a4458288..b6219f5e 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -19,7 +19,7 @@ jobs: - name: Build and start services with Docker Compose (CI Mode) run: | - CI=false COMMAND="npx serve -s build" docker compose up -d --build + CI=true COMMAND="npx serve -s build" docker compose up -d --build - name: Check running containers run: docker ps -a diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index b6219f5e..699b75d8 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -19,7 +19,7 @@ jobs: - name: Build and start services with Docker Compose (CI Mode) run: | - CI=true COMMAND="npx serve -s build" docker compose up -d --build + CI=true LINT=true COMMAND="npx serve -s build" docker compose up -d --build - name: Check running containers run: docker ps -a diff --git a/Dockerfile b/Dockerfile index 69183eae..26f865ff 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,8 @@ WORKDIR /app COPY my-app . RUN npm ci ARG CI=false +ARG LINT=false RUN if [ "$CI" = "true" ]; then npm run build; fi -RUN if [ "$CI" = "true" ]; then npm run lint; fi +RUN if [ "$LINT" = "true" ]; then npm run lint; fi EXPOSE 5173 CMD ["npm", "run", "dev"] From 86349e69abac3f915db89c3eaeb925d50867d4b3 Mon Sep 17 00:00:00 2001 From: Justus Kluge Date: Wed, 16 Apr 2025 13:25:52 +0200 Subject: [PATCH 10/11] Renaming actions --- .github/workflows/docker-build.yml | 2 +- .github/workflows/docker-image.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index b6219f5e..95568907 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -1,4 +1,4 @@ -name: Docker CI +name: Docker CI Build on: push: diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 699b75d8..e21428df 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -1,4 +1,4 @@ -name: Docker CI +name: Docker CI LINT on: push: From ef68016b83a246cbba2115b9157b1ceb99ec70c1 Mon Sep 17 00:00:00 2001 From: Justus Kluge Date: Thu, 17 Apr 2025 12:21:41 +0200 Subject: [PATCH 11/11] new docker --- docker-compose.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/docker-compose.yml b/docker-compose.yml index 731c689d..64dd9f4b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,6 +5,7 @@ services: dockerfile: Dockerfile args: - CI=${CI:-false} + - LINT=${LINT:-false} container_name: my-app ports: - "5173:5173"