diff --git a/.github/workflows/deploy-be-dockerimage.yaml b/.github/workflows/deploy-be-dockerimage.yaml new file mode 100644 index 000000000..e3d1a588f --- /dev/null +++ b/.github/workflows/deploy-be-dockerimage.yaml @@ -0,0 +1,31 @@ +name: Build and Push MPM Backend Image + +on: + push: + branches: + - deploy/docker-images + +jobs: + build-and-push: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + file: ./Docker/DockerfileLaravelProd + platforms: linux/amd64 + push: true + tags: enaccess/mpm-backend:latest diff --git a/.github/workflows/deploy-fe-dockerimage.yaml b/.github/workflows/deploy-fe-dockerimage.yaml new file mode 100644 index 000000000..18c20521a --- /dev/null +++ b/.github/workflows/deploy-fe-dockerimage.yaml @@ -0,0 +1,31 @@ +name: Build and Push MPM Frontend Image + +on: + push: + branches: + - deploy/docker-images + +jobs: + build-and-push: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + file: ./Docker/DockerfileUIProd + platforms: linux/amd64 + push: true + tags: enaccess/mpm-frontend:latest diff --git a/Website/ui/DockerfileServe b/Docker/DockerfileUIDev similarity index 57% rename from Website/ui/DockerfileServe rename to Docker/DockerfileUIDev index 5c56c706e..e1661f581 100644 --- a/Website/ui/DockerfileServe +++ b/Docker/DockerfileUIDev @@ -3,11 +3,11 @@ FROM node:18.20.4 WORKDIR /usr/app # Copy the package.json and install dependencies -COPY package*.json ./ +COPY ../Website/ui/package*.json ./ RUN npm install -# Copy rest of the files -COPY --chown=www-data:www-data . . +# Copy the rest of the files +COPY --chown=www-data:www-data ../Website/ui . EXPOSE 8080 diff --git a/Docker/DockerfileUIProd b/Docker/DockerfileUIProd new file mode 100644 index 000000000..b1855fe17 --- /dev/null +++ b/Docker/DockerfileUIProd @@ -0,0 +1,26 @@ +FROM node:18.20.4 + +# Install simple http server for serving static content +RUN npm install -g http-server + +# Make the 'app' folder the current working directory +WORKDIR /app + +# Copy 'package.json' and 'package-lock.json' +COPY ../Website/ui/package*.json ./ + +# Install project dependencies +RUN npm install + +# Force the upgrade of restore-cursor and onetime to the latest versions +RUN npm install restore-cursor@latest onetime@latest + +# Copy project files and folders to the current working directory (i.e. 'app' folder) +COPY ../Website/ui . + +# Build app for production with minification +RUN npm run build + +EXPOSE 8081 + +CMD [ "http-server", "dist", "-p", "8081" ] diff --git a/Website/ui/Dockerfile b/Website/ui/Dockerfile deleted file mode 100644 index 352661714..000000000 --- a/Website/ui/Dockerfile +++ /dev/null @@ -1,23 +0,0 @@ -FROM node:18.20.4 - -# install simple http server for serving static content -RUN npm install -g http-server - -# make the 'app' folder the current working directory -WORKDIR /app - -# copy both 'package.json' and 'package-lock.json' (if available) -COPY package*.json ./ - -# install project dependencies -RUN npm install - -# copy project files and folders to the current working directory (i.e. 'app' folder) -COPY . . - -# build app for production with minification -RUN npm run build - -EXPOSE 8081 - -CMD [ "http-server", "dist", "-p", "8081" ] \ No newline at end of file diff --git a/docs/development/build-for-production.md b/docs/development/build-for-production.md index 1d7aeb7ed..e86032fd4 100644 --- a/docs/development/build-for-production.md +++ b/docs/development/build-for-production.md @@ -15,9 +15,5 @@ docker build --platform linux/amd64 -t micropowermanager-laravel-prod -f Docker/ ## Frontend Prod ```bash -cd Website/ui -``` - -```bash -docker build --platform linux/amd64 -t micropowermanager-frontend-prod -f Dockerfile +docker build --platform linux/amd64 -t micropowermanager-ui-prod -f Docker/DockerfileUIProd . ```