Skip to content

Commit

Permalink
Upload Frontend image with nginx
Browse files Browse the repository at this point in the history
  • Loading branch information
Yamaguchi committed Jul 8, 2023
1 parent 6770254 commit 1749eb4
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 0 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/push_docker_image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,11 @@ jobs:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY_FRONTEND: ${{ secrets.AWS_ECR_REPO_NAME_FRONTEND }}
ECR_REPOSITORY_BACKEND: ${{ secrets.AWS_ECR_REPO_NAME_BACKEND }}
ECR_REPOSITORY_FRONTEND_NGINX: ${{ secrets.AWS_ECR_REPO_NAME_FRONTEND_NGINX }}
run: |
DOCKER_IMAGE_FRONTEND=tapyrus/explorer-frontend
DOCKER_IMAGE_BACKEND=tapyrus/explorer-backend
DOCKER_IMAGE_FRONTEND_NGINX=tapyrus/explorer-frontend-nginx
VERSION=noop
if [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
Expand All @@ -52,6 +54,7 @@ jobs:
fi
TAGS_FRONTEND="${DOCKER_IMAGE_FRONTEND}:${VERSION},${ECR_REGISTRY}/${ECR_REPOSITORY_FRONTEND}:${VERSION}"
TAGS_BACKEND="${DOCKER_IMAGE_BACKEND}:${VERSION},${ECR_REGISTRY}/${ECR_REPOSITORY_BACKEND}:${VERSION}"
TAGS_FRONTEND_NGINX="${DOCKER_IMAGE_FRONTEND_NGINX}:${VERSION},${ECR_REGISTRY}/${ECR_REPOSITORY_FRONTEND_NGINX}:${VERSION}"
if [[ $VERSION =~ ^v[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
MINOR=${VERSION%.*}
Expand All @@ -60,13 +63,17 @@ jobs:
TAGS_FRONTEND="$TAGS_FRONTEND,${ECR_REGISTRY}/${ECR_REPOSITORY_FRONTEND}:${MINOR},${ECR_REGISTRY}/${ECR_REPOSITORY_FRONTEND}:${MAJOR},${ECR_REGISTRY}/${ECR_REPOSITORY_FRONTEND}:latest"
TAGS_BACKEND="$TAGS_BACKEND,${DOCKER_IMAGE_BACKEND}:${MINOR},${DOCKER_IMAGE_BACKEND}:${MAJOR},${DOCKER_IMAGE_BACKEND}:latest"
TAGS_BACKEND="$TAGS_BACKEND,${ECR_REGISTRY}/${ECR_REPOSITORY_BACKEND}:${MINOR},${ECR_REGISTRY}/${ECR_REPOSITORY_BACKEND}:${MAJOR},${ECR_REGISTRY}/${ECR_REPOSITORY_BACKEND}:latest"
TAGS_FRONTEND_NGINX="$TAGS_FRONTEND_NGINX,${DOCKER_IMAGE_FRONTEND_NGINX}:${MINOR},${DOCKER_IMAGE_FRONTEND_NGINX}:${MAJOR},${DOCKER_IMAGE_FRONTEND_NGINX}:latest"
TAGS_FRONTEND_NGINX="$TAGS_FRONTEND_NGINX,${ECR_REGISTRY}/${ECR_REPOSITORY_FRONTEND_NGINX}:${MINOR},${ECR_REGISTRY}/${ECR_REPOSITORY_FRONTEND_NGINX}:${MAJOR},${ECR_REGISTRY}/${ECR_REPOSITORY_FRONTEND_NGINX}:latest"
elif [ "${{ github.event_name }}" = "push" ]; then
TAGS_FRONTEND="$TAGS_FRONTEND,${DOCKER_IMAGE_FRONTEND}:sha-${GITHUB_SHA::8},${ECR_REGISTRY}/${ECR_REPOSITORY_FRONTEND}:sha-${GITHUB_SHA::8}"
TAGS_BACKEND="$TAGS_BACKEND,${DOCKER_IMAGE_BACKEND}:sha-${GITHUB_SHA::8},${ECR_REGISTRY}/${ECR_REPOSITORY_BACKEND}:sha-${GITHUB_SHA::8}"
TAGS_FRONTEND_NGINX="$TAGS_FRONTEND_NGINX,${DOCKER_IMAGE_FRONTEND_NGINX}:sha-${GITHUB_SHA::8},${ECR_REGISTRY}/${ECR_REPOSITORY_FRONTEND_NGINX}:sha-${GITHUB_SHA::8}"
fi
echo ::set-output name=version::${VERSION}
echo ::set-output name=tags-frontend::${TAGS_FRONTEND}
echo ::set-output name=tags-backend::${TAGS_BACKEND}
echo ::set-output name=tags-frontend-nginx::${TAGS_FRONTEND_NGINX}
echo ::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ')
-
name: Set up QEMU
Expand Down Expand Up @@ -118,3 +125,22 @@ jobs:
org.opencontainers.image.created=${{ steps.prep.outputs.created }}
org.opencontainers.image.revision=${{ github.sha }}
org.opencontainers.image.licenses=${{ fromJson(steps.repo.outputs.result).license.spdx_id }}
-
name: Build and push nginx image
id: docker_build_nginx
uses: docker/build-push-action@v2
with:
context: ./nginx
file: ./nginx/Dockerfile
platforms: linux/amd64,linux/arm/v7,linux/arm64/v8
push: true
tags: ${{ steps.prep.outputs.tags-frontend-nginx }}
labels: |
org.opencontainers.image.title=${{ fromJson(steps.repo.outputs.result).name }}
org.opencontainers.image.description=${{ fromJson(steps.repo.outputs.result).description }}
org.opencontainers.image.url=${{ fromJson(steps.repo.outputs.result).html_url }}
org.opencontainers.image.source=${{ fromJson(steps.repo.outputs.result).clone_url }}
org.opencontainers.image.version=${{ steps.prep.outputs.version }}
org.opencontainers.image.created=${{ steps.prep.outputs.created }}
org.opencontainers.image.revision=${{ github.sha }}
org.opencontainers.image.licenses=${{ fromJson(steps.repo.outputs.result).license.spdx_id }}
7 changes: 7 additions & 0 deletions nginx/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM tapyrus/explorer-frontend:latest as builder
RUN npm run build -- --configuration=production

FROM nginx:1.17
COPY --from=builder /app/www /usr/share/nginx/html
COPY config.json /usr/share/nginx/html/assets
COPY nginx.conf /etc/nginx/conf.d/default.conf
4 changes: 4 additions & 0 deletions nginx/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"backendUrl": "https://testnet-explorer.tapyrus.dev.chaintope.com",
"project": "Tapyrus Testnet"
}
17 changes: 17 additions & 0 deletions nginx/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
server {
listen 80;
server_name localhost;

location / {
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri$args $uri$args/ /index.html;
}

# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}

0 comments on commit 1749eb4

Please sign in to comment.