Push Docker images to GitHub container registry

This commit is contained in:
Oliver Davies 2021-07-05 19:41:10 +01:00
parent 31eee68896
commit 0565c659fd
2 changed files with 18 additions and 4 deletions

View file

@ -14,7 +14,7 @@ RUN npm ci
COPY . . COPY . .
RUN npm run production RUN npm run production
FROM nginx AS nginx FROM nginx AS production
COPY tools/docker/images/nginx/root / COPY tools/docker/images/nginx/root /
WORKDIR /app WORKDIR /app
COPY --from=app /app/output_prod ./ COPY --from=app /app/output_prod ./

View file

@ -1,6 +1,9 @@
workspace('oliverdavies-uk'): workspace('oliverdavies-uk'):
description: Sculpin website for oliverdavies.uk. description: Sculpin website for oliverdavies.uk.
attribute('docker'):
repository: ghcr.io/opdavies/oliverdavies-uk-web
command('disable'): command('disable'):
env: env:
COMPOSE_PROJECT_NAME: = @('namespace') COMPOSE_PROJECT_NAME: = @('namespace')
@ -13,9 +16,20 @@ command('docker image build <git_commit>'):
COMPOSE_PROJECT_NAME: = @('namespace') COMPOSE_PROJECT_NAME: = @('namespace')
GIT_COMMIT_SHA: = input.argument('git_commit') GIT_COMMIT_SHA: = input.argument('git_commit')
exec: | exec: |
#!bash(workspace:/) #!bash(workspace:/)|@
docker image build -f tools/docker/images/Dockerfile -t ${COMPOSE_PROJECT_NAME}-web:latest --target=nginx . run docker image build -f tools/docker/images/Dockerfile --target=production -t @('docker.repository'):${GIT_COMMIT_SHA} .
docker image build -f tools/docker/images/Dockerfile -t ${COMPOSE_PROJECT_NAME}-web:${GIT_COMMIT_SHA} --target=nginx . run docker image build -f tools/docker/images/Dockerfile --target=production -t @('docker.repository'):latest .
command('docker image push <git_commit>'):
env:
COMPOSE_PROJECT_NAME: = @('namespace')
GIT_COMMIT_SHA: = input.argument('git_commit')
exec: |
#!bash(workspace:/)|@
ws docker image build $GIT_COMMIT_SHA
run docker push @('docker.repository'):${GIT_COMMIT_SHA}
run docker push @('docker.repository'):latest
command('enable'): command('enable'):
env: env: