diff --git a/.github/workflows/github-images.yml b/.github/workflows/github-images.yml index ac48bd3..824dfdf 100644 --- a/.github/workflows/github-images.yml +++ b/.github/workflows/github-images.yml @@ -15,8 +15,11 @@ jobs: - name: Log in to GitHub Container Registry run: echo ${{ secrets.PAT_DOCKER_IMAGES }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin + #- name: Set environment variable + # run: echo "DB_PASSWORD=${{ secrets.DB_PASSWORD }}" >> $GITHUB_ENV + - name: Build docker image - run: make build + run: make build DB_PASSWORD=${{ secrets.DB_PASSWORD }} - name: Publish docker image run: make publish \ No newline at end of file diff --git a/dockerfile b/dockerfile index b1e6d43..181fc54 100644 --- a/dockerfile +++ b/dockerfile @@ -1,7 +1,9 @@ FROM postgres:17.0 +ARG DB_PASSWORD + ENV POSTGRES_USER=admin -ENV POSTGRES_PASSWORD=Abc!1234 +ENV POSTGRES_PASSWORD=${DB_PASSWORD} ENV POSTGRES_DB=testdb COPY sql /docker-entrypoint-initdb.d/ \ No newline at end of file diff --git a/makefile b/makefile index 8ce4753..6a9e7b6 100644 --- a/makefile +++ b/makefile @@ -1,10 +1,10 @@ -IMAGE_NAME=postgresql-container +IMAGE_NAME=ghcr.io/fosouzadev/postgresql-container TAG=1.0 build: - docker build . -t ghcr.io/fosouzadev/$(IMAGE_NAME):$(TAG) - docker build . -t ghcr.io/fosouzadev/$(IMAGE_NAME):latest + docker build --build-arg DB_PASSWORD=$(DB_PASSWORD) . -t $(IMAGE_NAME):$(TAG) + docker build --build-arg DB_PASSWORD=$(DB_PASSWORD) . -t $(IMAGE_NAME):latest publish: - docker push ghcr.io/fosouzadev/$(IMAGE_NAME):$(TAG) - docker push ghcr.io/fosouzadev/$(IMAGE_NAME):latest \ No newline at end of file + docker push $(IMAGE_NAME):$(TAG) + docker push $(IMAGE_NAME):latest \ No newline at end of file