Skip to content

Commit

Permalink
Merge pull request #1750 from Mohmn/feat/build-next-images-in-docker
Browse files Browse the repository at this point in the history
feat: build nextjs images in dokcer images and update ci workflows
  • Loading branch information
Mohmn authored Feb 10, 2024
2 parents dfe5b65 + 44ff580 commit d407942
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 9 deletions.
7 changes: 7 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
node_modules/
.next
.vscode
.gitignore
README.md
.dockerignore
.git
8 changes: 8 additions & 0 deletions .env.test
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,11 @@ NEXT_PUBLIC_TILE_SERVER_SUBDOMAINS=test-k8s
NEXT_PUBLIC_API_NEW=http://127.0.0.1:4010/mock
NEXT_PUBLIC_BASE=/web-map-beta/demo
NEXT_PUBLIC_SERVER_CONFIG_DISABLED=true
NEXT_PUBLIC_BASE=
NEXT_PUBLIC_CONFIG_API=
NEXT_PUBLIC_COUNTRY_LEADER_BOARD_DISABLED=false
NEXT_PUBLIC_SERVER_CONFIG_DISABLED=true
NEXT_PUBLIC_KEYCLOAK_URL=https://test-k8s.treetracker.org/keycloak/realms/treetracker/
NEXT_PUBLIC_KEYCLOAK_CLIENT_ID=raw-client
NEXT_PUBLIC_KEYCLOAK_REALM=treetracker
NEXT_PUBLIC_KEYCLOAK_REDIRECT_URI=https://test.treetracker.org/
8 changes: 4 additions & 4 deletions .github/workflows/deploy-main-channel-to-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- name: Use Node.js 18.x
uses: actions/setup-node@v3
with:
node-version: '18.x'
node-version: '20.x'
- name: npm clean install
run: npm ci
working-directory: ${{ env.project-directory }}
Expand Down Expand Up @@ -59,9 +59,9 @@ jobs:
uses: docker/build-push-action@v2
with:
context: ./
file: ./Dockerfile
file: ./Dockerfile-dev
push: true
tags: greenstand/${{ github.event.repository.name }}:${{ steps.package-version.outputs.current-version }}
tags: greenstand/${{ github.event.repository.name }}-dev:${{ steps.package-version.outputs.current-version }}

- id: export_bumped_version
run: |
Expand All @@ -83,7 +83,7 @@ jobs:
- name: Install kustomize
run: curl -s "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash
- name: Run kustomize
run: (cd deployment/base && ../../kustomize edit set image greenstand/${{ github.event.repository.name }}:${{ needs.release.outputs.bumped_version }} )
run: (cd deployment/base && ../../kustomize edit set image greenstand/${{ github.event.repository.name }}-dev:${{ needs.release.outputs.bumped_version }} )
- name: Install doctl for kubernetes
uses: digitalocean/action-doctl@v2
with:
Expand Down
22 changes: 20 additions & 2 deletions .github/workflows/deploy-main-channel-to-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,36 @@ jobs:
- name: Use Node.js 18.x
uses: actions/setup-node@v1
with:
node-version: '18.x'
node-version: '20.x'
- name: get-npm-version
id: package-version
uses: martinbeentjes/npm-get-version-action@master
- id: export_bumped_version
run: |
export BUMPED_VERSION="${{ steps.package-version.outputs.current-version }}"
echo "bumped_version=${BUMPED_VERSION}" >> $GITHUB_OUTPUT
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Build and push
uses: docker/build-push-action@v5
with:
context: ./
push: true
file: ./Dockerfile-test
tags: greenstand/${{ github.event.repository.name }}-test:${{ steps.package-version.outputs.current-version }}
- name: Install kustomize
run: curl -s "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash
- name: Run kustomize
run: (cd deployment/base && ../../kustomize edit set image greenstand/${{ github.event.repository.name }}:${{ steps.export_bumped_version.outputs.bumped_version }} )
run: (cd deployment/base && ../../kustomize edit set image greenstand/${{ github.event.repository.name }}-test:${{ steps.export_bumped_version.outputs.bumped_version }} )
- name: Install doctl for kubernetes
uses: digitalocean/action-doctl@v2
with:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/dev-build-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ jobs:
uses: docker/build-push-action@v2
with:
context: ./
file: ./Dockerfile
file: ./Dockerfile-dev
push: true
tags: greenstand/${{ github.event.repository.name }}:${{ steps.package-version.outputs.current-version }}
tags: greenstand/${{ github.event.repository.name }}-dev:${{ steps.package-version.outputs.current-version }}

- id: export_bumped_version
run: |
Expand Down Expand Up @@ -109,7 +109,7 @@ jobs:
#- name: Print channel
# run: echo ${{ steps.channel.outputs.CHANNEL }}
- name: Run kustomize
run: (cd deployment/base && ../../kustomize edit set image greenstand/${{ github.event.repository.name }}:${{needs.release.outputs.bumped_version}} )
run: (cd deployment/base && ../../kustomize edit set image greenstand/${{ github.event.repository.name }}-dev:${{needs.release.outputs.bumped_version}} )
- name: Install doctl for kubernetes
uses: digitalocean/action-doctl@v2
with:
Expand Down
10 changes: 10 additions & 0 deletions Dockerfile-dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM node:16-alpine
WORKDIR /app
ENV PATH /app/node_modules/.bin:$PATH
COPY package.json ./
COPY package-lock.json ./
RUN npm ci --silent
COPY . ./
COPY .env.development .env.production
RUN npm run build
CMD [ "npm", "run", "start" ]
10 changes: 10 additions & 0 deletions Dockerfile-test
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM node:16-alpine
WORKDIR /app
ENV PATH /app/node_modules/.bin:$PATH
COPY package.json ./
COPY package-lock.json ./
RUN npm ci --silent
COPY . ./
COPY .env.test .env.production
RUN npm run build
CMD [ "npm", "run", "start" ]

0 comments on commit d407942

Please sign in to comment.