Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revamp milmove app to use cimg/base, include server_test deps #359

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ jobs:
docker tag milmove/circleci-docker:milmove-cypress milmove/circleci-docker:milmove-cypress-$tag
docker push milmove/circleci-docker:milmove-cypress-$tag

# milmove-playwright
docker tag milmove/circleci-docker:milmove-playwright milmove/circleci-docker:milmove-playwright-$tag
docker push milmove/circleci-docker:milmove-playwright-$tag

# milmove-infra-tf112
docker tag milmove/circleci-docker:milmove-infra-tf112 milmove/circleci-docker:milmove-infra-tf112-$tag
docker push milmove/circleci-docker:milmove-infra-tf112-$tag
Expand Down
3 changes: 3 additions & 0 deletions build
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ docker build --build-arg CACHE_APT="$CACHE_APT" \
-t milmove/circleci-docker:milmove-cypress \
-f milmove-cypress/Dockerfile .

docker build -t milmove/circleci-docker:milmove-playwright \
-f milmove-playwright/Dockerfile .

pushd milmove-infra-tf112
docker build -t milmove/circleci-docker:milmove-infra-tf112 \
.
Expand Down
36 changes: 33 additions & 3 deletions milmove-app/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CircleCI docker image to run within
FROM milmove/circleci-docker:base
# Use new convience images, use ubuntu 20.04 because postgresql does
# not provide version 12.11 for newer versions. We can upgrade the
# base image when we are on newer versions of postgresql in production
FROM cimg/base:2023.01-20.04

# Base image uses "circleci", to avoid using `sudo` run as root user
USER root

Expand Down Expand Up @@ -28,6 +32,16 @@ RUN set -ex && cd ~ \
&& tar -C /usr/local/bin -xzf ecs-service-logs_${ECS_SERVICE_LOGS_VERSION}_Linux_x86_64.tar.gz \
&& rm -v ecs-service-logs_${ECS_SERVICE_LOGS_VERSION}_Linux_x86_64.tar.gz

# install shellcheck
ARG SHELLCHECK_VERSION=0.7.1
ARG SHELLCHECK_SHA256SUM=64f17152d96d7ec261ad3086ed42d18232fcb65148b44571b564d688269d36c8
RUN set -ex && cd ~ \
&& curl -sSLO https://github.com/koalaman/shellcheck/releases/download/v${SHELLCHECK_VERSION}/shellcheck-v${SHELLCHECK_VERSION}.linux.x86_64.tar.xz \
&& [ $(sha256sum shellcheck-v${SHELLCHECK_VERSION}.linux.x86_64.tar.xz | cut -f1 -d' ') = ${SHELLCHECK_SHA256SUM} ] \
&& tar xvfa shellcheck-v${SHELLCHECK_VERSION}.linux.x86_64.tar.xz \
&& mv shellcheck-v${SHELLCHECK_VERSION}/shellcheck /usr/local/bin \
&& chown root:root /usr/local/bin/shellcheck \
&& rm -vrf shellcheck-v${SHELLCHECK_VERSION} shellcheck-v${SHELLCHECK_VERSION}.linux.x86_64.tar.xz

# apt-get project dependencies
# Notes:
Expand All @@ -43,16 +57,32 @@ RUN set -ex && cd ~ \
&& curl -o nodejs.deb https://deb.nodesource.com/node_16.x/pool/main/n/nodejs/nodejs_16.15.0-deb-1nodesource1_amd64.deb \
&& dpkg -i ./nodejs.deb \
&& rm nodejs.deb \
&& : Add Yarn \
&& : Add postgresql apt sources \
&& sh -c 'echo "deb http://apt-archive.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg-archive main" > /etc/apt/sources.list.d/pgdg.list' \
&& curl -sSLf -o - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \
&& : Add Yarn apt sources \
&& curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \
&& echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list \
&& apt-get -qq update \
&& : Install apt packages \
&& apt-get -qq -y install --no-install-recommends nodejs yarn entr postgresql-client \
&& : postgresql-12 pinning version \
&& : redis, no matter the version \
&& : python3-pip for pre-commit \
&& apt-get -qq -y install --no-install-recommends \
nodejs \
yarn \
entr \
postgresql-12=12.11-1.pgdg20.04+1 \
redis-server \
python3-pip \
&& : Cleanup \
&& apt-get clean \
&& rm -vrf /var/lib/apt/lists/*

# install exactly the version of pre-commit we want pinned now that we
# have pip installed
RUN pip install pre-commit==2.20.0

USER circleci

# Create GOPATH, needed for swagger, needs to be owned by circleci user
Expand Down
53 changes: 53 additions & 0 deletions milmove-playwright/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# CircleCI docker image to run within
FROM cimg/node:16.15.0-browsers

# Base image uses "circleci", to avoid using `sudo` run as root user
USER root

# apt-get project dependencies
# Notes:
# - When adding apt sources do it before 'apt-get update'
#
#
# Try cimg/node browsers image
# && : Install chrome deps via apt packages \
# && apt-get -qq update \
# && apt-get -qq -y install --no-install-recommends \
# libgtk2.0-0 \
# libgtk-3-0 \
# libgbm-dev \
# libnotify-dev \
# libgconf-2-4 \
# libnss3 \
# libxss1 \
# libasound2 \
# libxtst6 \
# xauth \
# xvfb \

# Try installing postgres and redis to see if we can run without
# remote docker
ARG CACHE_APT
RUN set -ex && cd ~ \
&& : Install postgresql-12 via apt packages, pinning version \
&& sh -c 'echo "deb http://apt-archive.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg-archive main" > /etc/apt/sources.list.d/pgdg.list' \
&& curl -sSLf -o - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \
&& apt-get -qq update \
&& apt-get -y install --no-install-recommends \
postgresql-12=12.11-1.pgdg20.04+1 \
&& : Install redis via apt packages, no matter the version \
&& apt-get -qq -y install --no-install-recommends \
redis-server \
&& : Cleanup \
&& apt-get clean \
&& rm -vrf /var/lib/apt/lists/*

# needed to set up path for yarn and node
RUN sed -i -e "s,bin/sh,bin/bash," /docker-entrypoint.sh

# create mymove workdir
WORKDIR /home/circleci/transcom/mymove
RUN chown -R circleci:circleci /home/circleci/transcom/mymove

USER circleci

14 changes: 13 additions & 1 deletion test
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@ function test_milmove_cypress() {
echo "Passed ${tag}"
}

function test_milmove_playwright() {
tag=milmove-playwright
echo "Testing ${tag} Dockerfile"

docker run -it "milmove/circleci-docker:${tag}" node --version

echo "Passed ${tag}"
}

function test_milmove_infra_tf132() {
tag=milmove-infra-tf132
echo "Testing ${tag} Dockerfile"
Expand All @@ -65,7 +74,7 @@ function test_milmove_infra_tf112() {
echo "Passed ${tag}"
}

for tag in latest milmove-app milmove-cypress milmove-infra-tf132 milmove-infra-tf112; do
for tag in latest milmove-app milmove-cypress milmove-playwright milmove-infra-tf132 milmove-infra-tf112; do
echo
echo "* Testing USER is properly set to 'circleci' on '${tag}' tagged image"
docker run -it "milmove/circleci-docker:${tag}" bash -xc '[[ $(whoami) = circleci ]]'
Expand All @@ -80,6 +89,9 @@ for tag in latest milmove-app milmove-cypress milmove-infra-tf132 milmove-infra-
milmove-cypress)
test_milmove_cypress
;;
milmove-playwright)
test_milmove_playwright
;;
milmove-infra-tf112)
test_milmove_infra_tf112
;;
Expand Down