Skip to content
Snippets Groups Projects
Commit c959242d authored by Edward Hicks's avatar Edward Hicks :8ball:
Browse files

switch to multistage build

parent dc134188
No related branches found
No related tags found
No related merge requests found
......@@ -11,8 +11,6 @@ stages:
awsauth:
stage: awsauth
image: registry.containers.it.osu.edu/cache/gitlab-org/cloud-deploy/aws-base:latest
rules:
- !reference [.default_rules, rules]
script:
- if [ "${AWS_ACCESS_KEY_ID}" = "" ]; then echo "Missing AWS_ACCESS_KEY_ID"; exit 1; fi
- if [ "${AWS_SECRET_ACCESS_KEY}" = "" ]; then echo "Missing AWS_SECRET_ACCESS_KEY"; exit 1; fi
......@@ -35,8 +33,6 @@ build:
needs:
- job: awsauth
artifacts: true
rules:
- !reference [.default_rules, rules]
script:
- if [ $CI_COMMIT_REF_SLUG = "master" -o $CI_COMMIT_REF_SLUG = "main" ]; then TAG="latest"; fi
- if [ "$AWS_ECR_TOKEN" != "" ]; then ECRARG="--destination ${AWS_ECR_REGISTRY}/${CI_PROJECT_NAME}:${TAG}"; fi
......@@ -59,7 +55,7 @@ build:
" > /kaniko/.docker/config.json
- |
/kaniko/executor \
--single-snapshot \
--single-snapshot --target main \
--context "${CI_PROJECT_DIR}" \
--git "branch=${CI_COMMIT_REF_SLUG},depth=1,single-branch=true,recurse-submodules=true,shallow-submodules=true" \
--dockerfile "${CI_PROJECT_DIR}/Dockerfile" \
......@@ -71,21 +67,8 @@ build:
dotenv: build.env
container_scanning:
rules:
- !reference [.default_rules, rules]
dependencies:
- build
include:
- template: Security/Container-Scanning.gitlab-ci.yml
.default_rules:
rules:
# - changes:
# - "*.md"
# - ".*ignore"
# - Makefile
# - runlocal.sh
# - merge-from-base.sh
# when: never
- when: always
FROM docker.io/node:22-bookworm
FROM docker.io/node:22-bookworm AS main
LABEL maintainer="E. Stuart Hicks <hicks.367@osu.edu>"
EXPOSE 3000
......@@ -44,7 +44,13 @@ RUN sed -E -i 's/^gshadow:(.*)$/gshadow:\1 ldap/' /etc/nsswitch.conf
# Final setup & cleanup
RUN apt-get -y clean
RUN rm -rf /var/lib/apt/lists/* /tmp/*
WORKDIR /var/www/nodejs
USER apache
CMD ["/bin/bash", "/usr/local/sbin/nodeserver.sh"]
# Final squash & setup
FROM scratch
COPY --from=main / /
WORKDIR /var/www/nodejs
CMD ["/usr/local/sbin/nodeserver.sh"]
USER apache
CMD ["/bin/bash", "/usr/local/sbin/nodeserver.sh"]
IMAGE = wheks-nodejs22
build:
DOCKER_BUILDKIT=0 docker build --platform linux/amd64 --squash --tag $(IMAGE) .
docker build --platform linux/amd64 --tag $(IMAGE) .
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment