Skip to content

Commit

Permalink
push docker image to ghcr
Browse files Browse the repository at this point in the history
  • Loading branch information
Andreas Goelzer committed Oct 4, 2024
1 parent d4a09f8 commit 5b384b9
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ jobs:
command: make teardown-integration-tests
- run:
name: Deploy Docker image / Helm Charts to ECR
command: make deploy-image
command: make deploy-image-ecr
- run:
name: Save test results
command: |
Expand Down
18 changes: 12 additions & 6 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,22 @@ jobs:
- name: Setup Integration Test Environment
run: |
make setup-integration-tests
# - name: Run Integration Tests
# run: |
# make run-integration-tests-only
- name: Run Integration Tests
run: |
make run-integration-tests-only
- name: Teardown Integration Test Environment
if: success() || failure()
run: |
make teardown-integration-tests
# - name: Deploy Docker image / Helm Charts to ECR
# run: |
# make deploy-image // TODO: implement github version
- name: 'Login to GHCR'
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{github.actor}}
password: ${{secrets.GITHUB_TOKEN}}
- name: Deploy Docker image to GHCR
run: |
./build_utils.sh uploadDockerImage
# - name: Save test results
# if: success() || failure()
# run: |
Expand Down
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ help: ## Display this help.
##@ Production Builds

.PHONY: all
all: run-integration-tests deploy-image ## build, test + deploy everything
all: run-integration-tests deploy-image-ecr ## build, test + deploy everything

.PHONY: build-image
build-image: ## build UI and create Docker image
@docker build -t "${IMG_REPO}:latest" -f docker/production/Dockerfile .
@docker build -t "${IMG_REPO}:latest" --build-arg "REACT_APP_GIT_SHA=${SHA}" -f docker/production/Dockerfile .

.PHONY: deploy-image
deploy-image: build-image ## deploy Docker image to AWS
.PHONY: deploy-image-ecr
deploy-image-ecr: build-image ## deploy Docker image to AWS
@if [ "${ECR_ACCOUNT_URL}" = "" ] ; then \
echo "ECR_ACCOUNT_URL environment variable must be set"; \
elif [ "${UNCOMMITTED}" != "" ] ; then \
Expand Down
15 changes: 15 additions & 0 deletions build_utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,21 @@ if [ "$1" == "uploadHelmPackage" ] ; then
exit 0
fi

if [ "$1" == "uploadDockerImage" ] ; then
DOCKER_IMAGE_TAG=$(getDockerImageTag)
if [ "${UNCOMMITTED}" != "" ] ; then
echo "Uncommitted changes in GIT. Will not push to GHCR."
echo "${UNCOMMITTED}"
exit 1
else
docker tag "nuodbaas-webui:latest" "${DOCKER_IMAGE_TAG}" && \
docker push "${DOCKER_IMAGE_TAG}"
fi

exit 0
fi

echo "$0 getDockerImageTag"
echo "$0 createHelmPackage"
echo "$0 uploadHelmPackage"
echo "$0 uploadDockerImage"
5 changes: 3 additions & 2 deletions docker/production/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

FROM node:18-alpine AS build-ui
WORKDIR /app/
COPY ui/public/ /app/public
COPY ui/src/ /app/src
ARG REACT_APP_GIT_SHA
COPY ui/package.json /app/
COPY ui/tsconfig.json /app/
RUN npm install
COPY ui/public/ /app/public
COPY ui/src/ /app/src
RUN npm run build

FROM nginx:alpine
Expand Down
4 changes: 2 additions & 2 deletions ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
"web-vitals": "^2.1.4"
},
"scripts": {
"start": "export REACT_APP_GIT_SHA=$(git rev-parse HEAD) && react-scripts start",
"build": "export REACT_APP_GIT_SHA=$(git rev-parse HEAD) && react-scripts build",
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --transformIgnorePatterns \"node_modules/(?!axios)/\"",
"eject": "react-scripts eject"
},
Expand Down

0 comments on commit 5b384b9

Please sign in to comment.