-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Redesign Build Deployment Process (External) #125
Changes from all commits
6aed57a
8b0317f
7d3cd86
355db20
3c17d18
e402a61
ffcdbc8
d6a6809
102899a
50a7b63
db85f75
2dab7a1
43f3d5a
89ed59a
37c7599
e962d13
8d2464d
d49a275
efaf216
baac678
629b3a1
fee9437
9622279
6e3f2be
1745634
21ca992
58093d3
368900b
bf3e9f7
6eebf87
e760598
9444e60
40beb80
29ebf49
1d0a937
308eca0
35e09cb
d919a34
11cdafb
1dda106
66bd0a6
426ae50
3b298fc
4335f39
b330f96
9b1dca5
ab0e157
7c78c18
27c2f42
c8b6dca
40bf355
803e9c2
7ee8e61
af3c2d3
91d5251
d3bf89f
c58b5dd
14775b5
f595b0d
2f17e5d
25dcba1
82cf4e9
5d7f6d8
cedf7b1
6849f84
f325eb3
eb4672c
e87058d
7483f2a
2434648
29353b0
b98cf53
8153155
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
SERVER_IMAGE_TAG=2024-08-12--15-15 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
name: docker-image-push-public-dash | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
|
||
workflow_dispatch: | ||
inputs: | ||
docker_image_tag: | ||
description: "Latest Docker image tags passed from e-mission-server repository on image build and push" | ||
required: true | ||
|
||
env: | ||
DOCKER_USER: ${{secrets.DOCKER_USER}} | ||
DOCKER_PASSWORD: ${{secrets.DOCKER_PASSWORD}} | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
env: | ||
DOCKER_TAG_FROM_WORKFLOW_DISPATCH: ${{ github.event.inputs.docker_image_tag }} | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set docker image tag from .env file | ||
run: | | ||
set -a; source .env; set +a | ||
echo "DOCKER_TAG_FROM_PUSH=${SERVER_IMAGE_TAG}" >> $GITHUB_ENV | ||
|
||
- name: Print input docker image tag | ||
run: | | ||
echo "Event name: ${{ github.event_name }}" | ||
echo "Latest docker image tag (push): ${{ env.DOCKER_TAG_FROM_PUSH }}" | ||
echo "Latest docker image tag (workflow_dispatch): ${{ env.DOCKER_TAG_FROM_WORKFLOW_DISPATCH }}" | ||
|
||
- name: Update .env file | ||
run: | | ||
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then | ||
echo "Workflow_dispatch: New server image built and pushed, Updating image tag in .env" | ||
echo "SERVER_IMAGE_TAG=$DOCKER_TAG_FROM_WORKFLOW_DISPATCH" > .env | ||
else | ||
echo "Push event: Restoring latest server image tag from .env" | ||
fi | ||
|
||
- name: Add, Commit, Push changes to .env file | ||
run: | | ||
git config --local user.email "[email protected]" | ||
git config --local user.name "Github Actions bot to update .env with latest tags" | ||
if git diff --quiet; then | ||
echo "Latest timestamp already present in .env file, no changes to commit" | ||
else | ||
git add .env | ||
git commit -m "Updated docker image tag in .env file to the latest timestamp" | ||
git push origin | ||
fi | ||
|
||
- name: docker login | ||
run: | # log into docker hub account | ||
docker login -u $DOCKER_USER -p $DOCKER_PASSWORD | ||
|
||
- name: Get current date # get the date of the build | ||
id: date | ||
run: echo "::set-output name=date::$(date +'%Y-%m-%d--%M-%S')" | ||
|
||
- name: Run a one-line script | ||
run: echo running in repo ${GITHUB_REPOSITORY#*/} branch ${GITHUB_REF##*/} on ${{ steps.date.outputs.date }} | ||
|
||
- name: build docker image | ||
run: | | ||
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then | ||
SERVER_IMAGE_TAG=$DOCKER_TAG_FROM_WORKFLOW_DISPATCH docker compose -f docker-compose.yml build | ||
else | ||
SERVER_IMAGE_TAG=$DOCKER_TAG_FROM_PUSH docker compose -f docker-compose.yml build | ||
fi | ||
docker images | ||
|
||
- name: rename docker images | ||
run: | | ||
if [ "${{ github.event_name }}" == "push" ]; then | ||
docker image tag em-pub-dash/frontend:latest $DOCKER_USER/${GITHUB_REPOSITORY#*/}_frontend:${GITHUB_REF##*/}_${{ steps.date.outputs.date }} | ||
fi | ||
docker image tag em-pub-dash/viz-scripts:latest $DOCKER_USER/${GITHUB_REPOSITORY#*/}_notebook:${GITHUB_REF##*/}_${{ steps.date.outputs.date }} | ||
|
||
- name: push docker images | ||
run: | | ||
if [ "${{ github.event_name }}" == "push" ]; then | ||
docker push $DOCKER_USER/${GITHUB_REPOSITORY#*/}_frontend:${GITHUB_REF##*/}_${{ steps.date.outputs.date }} | ||
fi | ||
docker push $DOCKER_USER/${GITHUB_REPOSITORY#*/}_notebook:${GITHUB_REF##*/}_${{ steps.date.outputs.date }} | ||
|
||
- name: Create a text file | ||
run: | | ||
echo ${{ steps.date.outputs.date }} > public_dash_tag_file.txt | ||
echo "Created tag text file" | ||
|
||
- name: Upload Artifact | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: public-dash-image-tag | ||
path: public_dash_tag_file.txt | ||
overwrite: true | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -108,7 +108,6 @@ celerybeat.pid | |
*.sage.py | ||
|
||
# Environments | ||
.env | ||
.venv | ||
env/ | ||
venv/ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,8 +18,10 @@ services: | |
notebook-server: | ||
image: em-pub-dash-dev/viz-scripts | ||
build: | ||
context: viz_scripts | ||
dockerfile: docker/Dockerfile.dev | ||
context: viz_scripts | ||
dockerfile: docker/Dockerfile.dev | ||
args: | ||
SERVER_IMAGE_TAG: ${SERVER_IMAGE_TAG} | ||
Comment on lines
+23
to
+24
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the expectation that the user will set the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, the user will not be required to manually set the image tags at any point. The args will be read in from the It builds the image successfully.
Some logs from
|
||
depends_on: | ||
- db | ||
environment: | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note that you should also remove the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This file does use this variable in setting the PYTHONPATH.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shankari the point of the artifact is to allow the internal repo to access the new tag outside of the run (see the internal repo PR and
commit 7ee8e61 )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. I still think we should be able to use tags and
.env
files instead, but will defer that discussion until the cleanup/polish