Skip to content

Commit

Permalink
multistage docker, read tag name from file
Browse files Browse the repository at this point in the history
  • Loading branch information
bunnyshell-eaas-migrations committed Mar 11, 2024
1 parent 1253e7f commit a77d149
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
10 changes: 9 additions & 1 deletion .github/workflows/build_docker_image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,24 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2


- name: read tags
run: |
echo "VERSION=0.0.4" >> $GITHUB_ENV
- name: debug
run: |
echo "TEST ${{ secrets.DOCKERHUB_USERNAME }} ${{ secrets.DOCKERHUB_TOKEN }} credentials"
echo "VERSION=${{ env.VERSION }}"
- name: Login to DockerHub XXXX
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}


-
name: Docker meta
id: docker_meta
Expand All @@ -49,7 +57,7 @@ jobs:
# tags: ${{ inputs.tag-rules }}
tags: |
latest
0.0.3
${{ env.VERSION }}

# - name: Build and push
Expand Down
16 changes: 14 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
from nginx:alpine
from alpine as build

RUN apk add --no-cache sed
COPY app/ /app
RUN ls -alh /app
RUN echo "test"
RUN export version=$(cat /app/version.txt) && echo $version
RUN sed -i'' "s/--version--/$version/g" /app/index.html


from nginx:alpine as prod


COPY --from=build /app /usr/share/nginx/html


COPY app /usr/share/nginx/html
4 changes: 2 additions & 2 deletions app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<div class="collapse navbar-collapse justify-content-center" id="navbarNav">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#">Home</a>
<a class="nav-link active" aria-current="page" href="#">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Features</a>
Expand All @@ -27,7 +27,7 @@
<a class="nav-link" href="#">Pricing</a>
</li>
<li class="nav-item">
<a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true">v0.0.2</a>
<a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true">--version--</a>
</li>
</ul>
</div>
Expand Down

0 comments on commit a77d149

Please sign in to comment.