diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 996c59b..e3d0375 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,9 +1,10 @@ -image: "gitlab/dind" - stages: - build - dockerize +variables: + CONTAINER_IMAGE: registry.gitlab.com/ahmza/blog:latest + Build: stage: build image: alpine:latest @@ -20,8 +21,11 @@ Build: Dockerize: stage: dockerize - before_script: - - docker login registry.gitlab.com -u ahmza -p $CI_DOCKER_ACCESS_TOKEN - script: - - docker build -t registry.gitlab.com/ahmza/blog . - - docker push registry.gitlab.com/ahmza/blog + image: + name: gcr.io/kaniko-project/executor:debug + entrypoint: [""] + script: + - mkdir -p /kaniko/.docker + - echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json + - /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG + - /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination $CI_REGISTRY_IMAGE:latest diff --git a/Dockerfile b/Dockerfile index ca58b1e..13bcf9e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,5 @@ -FROM alpine:latest -RUN which curl || ( apk update && apk add curl ) -RUN curl -L https://github.com/gohugoio/hugo/releases/download/v0.90.0/hugo_0.90.0_Linux-64bit.tar.gz > hugo.tar.gz -RUN tar -zxf hugo.tar.gz -RUN mv hugo /usr/local/bin/hugo -CMD hugo +FROM nginx:alpine +COPY .build /var/www +COPY nginx.conf /etc/nginx/nginx.conf +EXPOSE 80 +ENTRYPOINT ["nginx","-g","daemon off;"] diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..ed17d0c --- /dev/null +++ b/nginx.conf @@ -0,0 +1,36 @@ +http { + include /etc/nginx/mime.types; + default_type application/octet-stream; + log_format compression '$remote_addr - $remote_user [$time_local] ' + '"$request" $status $upstream_addr ' + '"$http_referer" "$htpp_user_agent"'; + + server { + listen 80; + access_log /var/log/nginx/access.log compression; + + root /var/www; + index index.html index.htm; + + location / { + try_files $uri $uri/ /index.html; + } + + location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc)$ { + expires 1M; + access_log off; + add_header Cache-Control "public"; + } + + location ~* \.(?:css|js)$ { + try_files $uri =404; + expires 1y; + access_log off; + add_header Cache-Control "public"; + } + + location ~ ^.+\..+$ { + try_files $uri =404; + } + } +}