-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a2ea2bc
commit 50220eb
Showing
3 changed files
with
76 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Create the image with Nginx environment. | ||
FROM nginx:alpine | ||
|
||
# Copy results from the dist folder to the image. | ||
ARG DIST_FOLDER | ||
RUN [ -z "$DIST_FOLDER" ] && echo "DIST_FOLDER is required" && exit 1 || true | ||
COPY $DIST_FOLDER /usr/share/nginx/html | ||
|
||
# Remove source maps from the production build | ||
RUN find /usr/share/nginx/html -name "*.map" -type f -delete | ||
|
||
# Copy the entrypoint. | ||
ARG ENV_RUNTIME_ENTRYPOINT | ||
RUN [ -z "$ENV_RUNTIME_ENTRYPOINT" ] && echo "ENV_RUNTIME_ENTRYPOINT is required" && exit 1 || true | ||
COPY $ENV_RUNTIME_ENTRYPOINT /usr/local/bin/env-runtime.entrypoint.sh | ||
RUN chmod +x /usr/local/bin/env-runtime.entrypoint.sh | ||
|
||
# version is used in build process, so the value won't be available here otherwise | ||
ARG VERSION | ||
RUN [ -z "$VERSION" ] && echo "VERSION is required" && exit 1 || true | ||
ENV DAVINCI_RELEASE_VERSION $VERSION | ||
|
||
RUN echo $VERSION > /usr/share/nginx/html/REVISION.txt | ||
|
||
# Copy configuration file for Nginx and replace the default one. | ||
ARG NGINX_CONFIG | ||
RUN [ -z "$NGINX_CONFIG" ] && echo "NGINX_CONFIG is required" && exit 1 || true | ||
COPY $NGINX_CONFIG /etc/nginx/conf.d/default.conf.templ | ||
|
||
ARG HTML_CDN_CACHE_TAG="davinci-app" | ||
ENV HTML_CDN_CACHE_TAG=${HTML_CDN_CACHE_TAG} | ||
|
||
# Entry point to provide Run Time Environment Variables for the App. | ||
ENTRYPOINT ["/usr/local/bin/env-runtime.entrypoint.sh"] | ||
|
||
CMD ["nginx", "-g", "daemon off;"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ description: | | |
envInputs: | ||
GITHUB_TOKEN: GitHub token. Is used to checkout `davinci` branch | ||
GCR_ACCOUNT_KEY: Necessary token to push image to Google cloud | ||
TOPTAL_BUILD_BOT_SSH_KEY: SSH key to access Google cloud | ||
inputs: | ||
sha: | ||
|
@@ -21,52 +22,43 @@ inputs: | |
required: true | ||
description: 'Multiline string to describe build arguments that will be used during dockerization' | ||
docker-file: | ||
description: 'pathname to Docker file' | ||
description: 'pathname to Dockerfile' | ||
required: false | ||
default: ./davinci/packages/ci/src/configs/docker/Dockerfile.gha-deploy | ||
davinci-branch: | ||
description: 'Custom davinci branch' | ||
required: false | ||
default: 'master' | ||
node-version: | ||
required: false | ||
default: 18 | ||
description: 'Node.js version used. The action is guaranteed to work only with Node.js@18 (default value)' | ||
default: Dockerfile | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: Check out davinci | ||
uses: actions/checkout@v3 | ||
with: | ||
repository: toptal/davinci | ||
token: ${{ env.GITHUB_TOKEN }} | ||
path: davinci | ||
ref: ${{ inputs.davinci-branch }} | ||
|
||
- name: Set up node | ||
uses: actions/[email protected] | ||
with: | ||
node-version: ${{ inputs.node-version }} | ||
|
||
- id: meta-latest | ||
shell: bash | ||
env: | ||
ENVIRONMENT: ${{ inputs.environment }} | ||
run: | | ||
latest=$(if [[ $ENVIRONMENT == 'temploy' ]]; then echo false; else echo true; fi) | ||
echo latest=$latest >> $GITHUB_OUTPUT | ||
echo "APP_VERSION=$(git describe --tags --always)" >> $GITHUB_ENV | ||
echo "COMMIT=$(git rev-parse HEAD)" >> $GITHUB_ENV | ||
- name: Docker meta | ||
uses: docker/metadata-action@v5 | ||
id: meta | ||
uses: docker/[email protected] | ||
with: | ||
images: | | ||
us-central1-docker.pkg.dev/toptal-hub/containers/${{ inputs.image-name }} | ||
tags: | | ||
type=raw,enable=true,priority=200,prefix=,suffix=,value=${{ inputs.sha }} | ||
type=sha,enable=true,format=long | ||
type=raw,enable=true,value=${{ github.head_ref }} | ||
type=raw,enable=true,value=${{ env.APP_VERSION }} | ||
type=raw,enable=true,value=${{ env.COMMIT }} | ||
type=raw,enable=true,value=master,enable=${{ github.head_ref == 'ci-3421-move-build-image-gha' }} | ||
flavor: | | ||
latest=${{ steps.meta-latest.outputs.latest }} | ||
# latest=false | ||
- name: Use SSH key | ||
uses: toptal/[email protected] | ||
with: | ||
ssh-private-key: ${{ env.TOPTAL_BUILD_BOT_SSH_KEY }} | ||
|
||
- name: Login to Google Artifact Registry - GAR | ||
uses: docker/login-action@v3 | ||
|
@@ -75,16 +67,24 @@ runs: | |
username: _json_key | ||
password: ${{ env.GCR_ACCOUNT_KEY }} | ||
|
||
- name: Set up Docker Buildx | ||
id: buildx | ||
- name: Set up Dcoker Buildx - CI custom runners | ||
if: contains(runner.name, 'inf-gha-runners-runners') | ||
uses: docker/setup-buildx-action@v3 | ||
with: | ||
driver: remote | ||
endpoint: 'tcp://10.154.0.46:1234' | ||
|
||
- name: Set up Docker Buildx - GH runners | ||
if: "!contains(runner.name, 'inf-gha-runners-runners')" | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Build and push release image | ||
uses: docker/build-push-action@v5.1.0 | ||
uses: docker/build-push-action@v5 | ||
with: | ||
provenance: false | ||
tags: ${{ steps.meta.outputs.tags }} | ||
push: true | ||
context: . | ||
file: ${{ inputs.docker-file }} | ||
build-args: ${{ inputs.build-args }} | ||
ssh: default |