如何把一個檔案包成docker_image,以下是一個範例:
首先要先建立一個Dockerfile:
FROM python:3.9.10-alpine3.15
# ADD . /test-project
COPY ./app /test-project
WORKDIR /test-project
RUN pip install -r requirements.txt
EXPOSE 5000
CMD ["gunicorn", "--bind", "0.0.0.0:5000", "app:app", "--preload"]
stages:
- build
- test
build-docker-image:
image: docker:latest
stage: build
tags:
- docker
script:
- docker build -t hello .
lint-test-job:
tags:
- macos
stage: test
script:
- echo "Linting code... This will take about 10 seconds."
- echo "No lint issues found."
當你在流水線看到這樣基本上你就已經完成了。