SIOS-Technology-Inc / dacrane

"Dacrane" is a Delivery as Code (DaC) tool for deploying cloud infrastructures and applications anywhere.
Apache License 2.0
61 stars 1 forks source link

Generate Dockerfile automatically #14

Closed t-ikeda-sti closed 1 year ago

t-ikeda-sti commented 1 year ago

User Story

Developers want to build container images without having to write a Dockerfile for the standard build method. For example, after executing a build such as go build or npm ci, you need to run ./executable and npm start.

Acceptance Criteria

The following will cause npm to build JavaScript on docker.

import: https://github.com/.../.../docker-npm.yaml
name: api
modules:
- name: api
  module: docker-npm

Together with #18, the following modules should be defined. This issue implements a file resource provider since there are not enough file resources.

name: docker-npm
argument:
- name: version
  default: 16.20.1
- name: src_files
  default: "**/*.js"
- name: package
  default: ./package.json
- name: package-lock
  default: ./package-lock.json
- name: build
  default: npm ci
- name: run
  default: npm start
modules:
- name: dockerfile
  provider: resource/file
  parameters:
    filename: ./Dockerfile
    contents: >
      FROM node:${{ arg.version }}-alpine3.18

      COPY ${{ arg.src_files }} ${{ arg.src_files }}
      COPY ${{ }} ${{ }}
      COPY ./package-lock.json ./package-lock.json

      RUN npm ci

      CMD [ "npm", "start" ]
  - name: docker_build
    provider: artifact/docker
    parameters:
      name: ...
      image: ...
      tag: ...
      port: ...
      env:  ...
t-ikeda-sti commented 1 year ago

@ka-sasaki-sti Please suggest a specification and design for the user story.

t-ikeda-sti commented 1 year ago

@ka-sasaki-sti Please implement file resource provider.

ka-sasaki-sti commented 1 year ago

@t-ikeda-sti Please check this PR #21 thank you!!

t-ikeda-sti commented 1 year ago

I have reviewed and merged. Thank you for the implementation!