Deploy Angular project to staging server with ftp

Hey,

I got stucked at deploying my Angular application to a web space.
The steps I want do go is:

  1. Test the Application
  2. Build the Application
  3. Deploy to server with ftp

So I created this gitlab-ci.yml file:

 image: node:latest
cache:
  key: "$CI_BUILD_REF_NAME"
  untracked: true
  paths:
    - node_modules/
    - dist/

stages:
  - build
# - test
  - deploy
  - cleanup
# - deployProd

runBuild:
  before_script:
   - apt-get install -y lftp
   - npm install -g angular-cli
   - npm install
  stage: build
  script:
    - ng build --target=production --environment=test
  except:
    - tags

runProdBuild:
  before_script:
   - npm install -g angular-cli
   - npm install
  stage: build
  script:
    - ng build --target=production --environment=prod
  only:
    - tags



runDeployTest:
  before_script:
    - apt-get install -y lftp
  variables:
    DATABASE: ""
    URL: "http://test.domain.de"
  stage: deploy
  environment:
      name: Entwicklungssystem
      url: https://test.domain.de
  artifacts:
    name: "$CI_BUILD_NAME/$CI_BUILD_REF_NAME"
    paths:
    - dist/
    expire_in: 2d
  except:
      - tags
  script:
    - echo '<?php ini_set("max_execution_time", 300);  function rrmdir($dir) {    if (is_dir($dir))    {        $objects = scandir($dir);        foreach ($objects as $object)       {            if ($object != "." && $object != "..")            {                if (is_dir($dir."/".$object))                {                    rrmdir($dir."/".$object);      }        else          {  echo "unlink :".$dir."/".$object;      unlink($dir."/".$object);     } }     }     rmdir($dir);     } } rrmdir(__DIR__."."); ?>' > delete.php
    - lftp -d -c "set ftp:ssl-allow no; open -u $ftp_user,$ftp_password $ftp_server; cd $ftp_path; put -O . delete.php"
    - wget "$URL/delete.php"
    - cd ./dist
    - zip -r install.zip .
    - lftp -d -c "set ftp:ssl-allow no; open -u $ftp_user,$ftp_password $ftp_server; cd $ftp_path; put -O . install.zip"
    - echo "<?php   \$dateiname = __DIR__.'/install.zip';   \$ofolder = str_replace('/public','',__DIR__);  exec('unzip '.\$dateiname.' -d '.\$ofolder.' 2>&1', \$out);   print(implode('<br>', \$out)); unlink(\$dateiname); unlink('entpacker.php'); unlink(__DIR__.'/../delete.php'); unlink(__DIR__.'/../delete.php.1'); ?>" > entpacker.php
    - lftp -d -c "set ftp:ssl-allow no; open -u $ftp_user,$ftp_password $ftp_server; cd $ftp_path; put -O . entpacker.php"
    # Install
    - wget $URL/entpacker.php

runDeployProd:
  before_script:
    - apt-get install -y lftp
  variables:
    DATABASE: ""
    URL: "http://test.domain.de"
  stage: deploy
  environment:
    name: Produktivsystem
    url: https://anmeldung.domain.de
  artifacts:
    name: "$CI_BUILD_NAME/$CI_BUILD_REF_NAME"
    paths:
      - dist/
    expire_in: 2d
  script:
    - echo '<?php ini_set("max_execution_time", 300);  function rrmdir($dir) {    if (is_dir($dir))    {        $objects = scandir($dir);        foreach ($objects as $object)       {            if ($object != "." && $object != "..")            {                if (is_dir($dir."/".$object))                {                    rrmdir($dir."/".$object);      }        else          {  echo "unlink :".$dir."/".$object;      unlink($dir."/".$object);     } }     }     rmdir($dir);     } } rrmdir(__DIR__."."); ?>' > delete.php
    - lftp -d -c "set ftp:ssl-allow no; open -u $ftp_user,$ftp_password $ftp_server; cd $ftp_path; put -O . delete.php"
    - wget "$URL/delete.php"
    - cd ./dist
    - zip -r install.zip .
    - lftp -d -c "set ftp:ssl-allow no; open -u $ftp_user,$ftp_password $ftp_server; cd $ftp_path; put -O . install.zip"
    - echo "<?php   \$dateiname = __DIR__.'/install.zip';   \$ofolder = str_replace('/public','',__DIR__);  exec('unzip '.\$dateiname.' -d '.\$ofolder.' 2>&1', \$out);   print(implode('<br>', \$out)); unlink(\$dateiname); unlink('entpacker.php'); unlink(__DIR__.'/../delete.php'); unlink(__DIR__.'/../delete.php.1'); ?>" > entpacker.php
    - lftp -d -c "set ftp:ssl-allow no; open -u $ftp_user,$ftp_password $ftp_server; cd $ftp_path; put -O . entpacker.php"
    # Install
    - wget $URL/entpacker.php
  only:
      - tags


cleanup:
  stage: cleanup
  script:
  - rm -rf ./dist
  - rm -rf ./node_modules
  when: manual

But I allways get the Error:

$ apt-get install -y lftp
Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package lftp

Does anyone have a suggestion how to handle this ?

I also tried to write my own docker image but I can’t get this running.

Hi. Please update apt cache before

apt-get update
apt-get install -y lftp

Hey thank you for this. This solves my problem.