From 042a2639f14b09658849813938d6945b006b8bad Mon Sep 17 00:00:00 2001 From: Vusumuzi Khoza Date: Tue, 25 Nov 2025 22:28:18 +0200 Subject: [PATCH] adding ci --- .gitlab-ci.yml | 32 ++++++++++++++++++++++++++++++++ Dockerfile | 2 +- Dockerfile-lab | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 .gitlab-ci.yml create mode 100644 Dockerfile-lab diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..d40aa20 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,32 @@ +image: docker:19.03.1 + +variables: + REGISTRY: 144.91.121.112:8082 + DEV_TAG: qpay-web:0.0.1-SNAPSHOT + TAG: qpay-web:0.0.1-RELEASE + DOCKER_OPTS: "--insecure-registry=$REGISTRY" + +stages: + - lab + - prod + +before_script: + - docker info + - docker login -u admin -p 1aae6202-7d42-44e4-bdc7-d988a95fdfe2 $REGISTRY + +lab: + stage: lab + script: + - docker build -f Dockerfile-lab -t "$REGISTRY/$DEV_TAG" . + - docker push "$REGISTRY/$DEV_TAG" + only: + - develop + +prod: + stage: prod + script: + - docker build -f Dockerfile -t "$REGISTRY/$TAG" . + - docker push "$REGISTRY/$TAG" + only: + - master + - release/0.0.1-RELEASE diff --git a/Dockerfile b/Dockerfile index 6191ff1..3ab557d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,7 +7,7 @@ RUN apt-get install -y curl git unzip # define variables ARG FLUTTER_SDK=/usr/local/flutter -ARG FLUTTER_VERSION=3.31.0 +ARG FLUTTER_VERSION=3.35.6 ARG APP=/app/ #clone flutter diff --git a/Dockerfile-lab b/Dockerfile-lab new file mode 100644 index 0000000..3ab557d --- /dev/null +++ b/Dockerfile-lab @@ -0,0 +1,47 @@ +# Environemnt to install flutter and build web +FROM debian:latest AS build-env + +# install all needed stuff +RUN apt-get update +RUN apt-get install -y curl git unzip + +# define variables +ARG FLUTTER_SDK=/usr/local/flutter +ARG FLUTTER_VERSION=3.35.6 +ARG APP=/app/ + +#clone flutter +RUN git clone https://github.com/flutter/flutter.git $FLUTTER_SDK +# change dir to current flutter folder and make a checkout to the specific version +RUN cd $FLUTTER_SDK && git fetch && git checkout $FLUTTER_VERSION + +# setup the flutter path as an enviromental variable +ENV PATH="$FLUTTER_SDK/bin:$FLUTTER_SDK/bin/cache/dart-sdk/bin:${PATH}" + +# Start to run Flutter commands +# doctor to see if all was installes ok +RUN flutter doctor -v + +# create folder to copy source code +RUN mkdir $APP +# copy source code to folder +COPY . $APP +# stup new folder as the working directory +WORKDIR $APP + +# Run build: 1 - clean, 2 - pub get, 3 - build web +RUN flutter clean +RUN flutter pub get +RUN flutter build web + +# once heare the app will be compiled and ready to deploy + +# use nginx to deploy +FROM nginx:1.25.2-alpine + +# copy the info of the builded web app to nginx +COPY --from=build-env /app/build/web /usr/share/nginx/html + +# Expose and run nginx +EXPOSE 80 +CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file