When I make changes to my code and push the changes, the CI pipeline is triggered, and it builds and pushes the Docker image to the GitHub Container Registry. However, it seems that when I pull the image, the changes are not present. Am I doing something wrong in my CI workflow? Here's my file:
name: Continuous Integration
on:
push:
branches:
- main
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Log in to the Container registry
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Build and push Docker image
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: ghcr.io/${{ github.repository_owner }}/myreponame:new
When I first change the tag of the image (here I have it set to "new"), I can see my new changes in my newly built image, but if I don't modify the tag, the changes don't get applied.
Here's my dockerfile if it can help:
# Build stage
FROM maven:3-openjdk-17-slim AS build
COPY src /home/app/src
COPY pom.xml /home/app/pom.xml
COPY wait-for-it.sh /home/app/wait-for-it.sh
RUN chmod +x /home/app/wait-for-it.sh
RUN mvn -f /home/app/pom.xml clean package
# Package stage
FROM openjdk:17-alpine
RUN apk add --no-cache bash
COPY --from=build /home/app/target/api.jar /usr/local/lib/api.jar
COPY --from=build /home/app/wait-for-it.sh /usr/local/bin/wait-for-it.sh
ENTRYPOINT ["/usr/local/bin/wait-for-it.sh", "db:5432", "--", "java", "-jar", "/usr/local/lib/api.jar"]