diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 374a790..8708120 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -3,6 +3,8 @@ name: Docker Image CI on: push: branches: [main, dev, release/*] + tags: + - 'v*' pull_request: branches: [main] @@ -29,13 +31,26 @@ jobs: key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} restore-keys: | ${{ runner.os }}-maven- + + - name: Extract Git metadata + id: vars + run: | + echo "GIT_SHA_SHORT=$(git rev-parse --short HEAD)" >> $GITHUB_ENV + echo "BRANCH_NAME=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV + echo "GIT_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV + - name: Build and push FITSInn REST - uses: docker/build-push-action@v5 - with: - context: . - platforms: linux/amd64,linux/arm64 - push: true - tags: artourkin/fitsinn-rest:${{ github.ref_name }} + run: | + IMAGE_NAME=artourkin/fitsinn-rest + CONTEXT=. + if [ "${{ github.ref }}" == "refs/heads/main" ]; then + docker buildx build --push --tag $IMAGE_NAME:latest $CONTEXT + elif [[ "${{ github.ref }}" == refs/tags/* ]]; then + docker buildx build --push --tag $IMAGE_NAME:${{ steps.vars.outputs.GIT_TAG }} $CONTEXT + else + docker buildx build --push --tag $IMAGE_NAME:${{ steps.vars.outputs.BRANCH_NAME }}-${{ steps.vars.outputs.GIT_SHA_SHORT }} $CONTEXT + fi + - name: Cache node modules id: cache-npm uses: actions/cache@v3 @@ -53,17 +68,29 @@ jobs: name: List the state of node modules continue-on-error: true run: npm list + - name: Build and push FITSInn WEB - uses: docker/build-push-action@v5 - with: - file: ./web/Dockerfile - platforms: linux/amd64,linux/arm64 - push: true - tags: artourkin/fitsinn-web:${{ github.ref_name }} + run: | + IMAGE_NAME=artourkin/fitsinn-web + CONTEXT=./web + if [ "${{ github.ref }}" == "refs/heads/main" ]; then + docker buildx build --push --tag $IMAGE_NAME:latest $CONTEXT + elif [[ "${{ github.ref }}" == refs/tags/* ]]; then + docker buildx build --push --tag $IMAGE_NAME:${{ steps.vars.outputs.GIT_TAG }} $CONTEXT + else + docker buildx build --push --tag $IMAGE_NAME:${{ steps.vars.outputs.BRANCH_NAME }}-${{ steps.vars.outputs.GIT_SHA_SHORT }} $CONTEXT + fi + - name: Build and push FITS WEB - uses: docker/build-push-action@v5 - with: - file: ./fits/Dockerfile - platforms: linux/amd64,linux/arm64/v8 - push: true - tags: artourkin/fits-web:${{ github.ref_name }} + run: | + IMAGE_NAME=artourkin/fits-web + CONTEXT=./fits + if [ "${{ github.ref }}" == "refs/heads/main" ]; then + docker buildx build --push --tag $IMAGE_NAME:latest $CONTEXT + elif [[ "${{ github.ref }}" == refs/tags/* ]]; then + docker buildx build --push --tag $IMAGE_NAME:${{ steps.vars.outputs.GIT_TAG }} $CONTEXT + else + docker buildx build --push --tag $IMAGE_NAME:${{ steps.vars.outputs.BRANCH_NAME }}-${{ steps.vars.outputs.GIT_SHA_SHORT }} $CONTEXT + fi + + diff --git a/docker-compose.clickhouse.dev.yaml b/docker-compose.clickhouse.dev.yaml index 5b9d14a..835e06e 100644 --- a/docker-compose.clickhouse.dev.yaml +++ b/docker-compose.clickhouse.dev.yaml @@ -4,8 +4,8 @@ services: fits: build: - context: . - dockerfile: ./fits/Dockerfile + context: ./fits + dockerfile: ./Dockerfile container_name: fits env_file: .env networks: @@ -34,8 +34,8 @@ services: web: build: - context: . - dockerfile: ./web/Dockerfile + context: ./web + dockerfile: ./Dockerfile container_name: web env_file: .env networks: diff --git a/web/Dockerfile b/web/Dockerfile index ff487cb..9e948dd 100644 --- a/web/Dockerfile +++ b/web/Dockerfile @@ -5,19 +5,19 @@ FROM node:14.5.0-stretch-slim as build WORKDIR /app ENV PATH /app/node_modules/.bin:$PATH -COPY ./web/frontend/package.json ./ -COPY ./web/frontend/package-lock.json ./ +COPY ./frontend/package.json ./ +COPY ./frontend/package-lock.json ./ RUN npm ci RUN npm install react-scripts@3.4.1 -g -COPY ./web/frontend ./ +COPY ./frontend ./ RUN npm run build FROM nginx:stable-alpine-slim COPY --from=build /app/build /usr/share/nginx/html -COPY ./web/nginx/nginx.conf /etc/nginx/conf.d/default.conf +COPY ./nginx/nginx.conf /etc/nginx/conf.d/default.conf EXPOSE 3000 CMD ["nginx", "-g", "daemon off;"]