0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【Docker】Dockerfileでヒアドキュメントを使用する

Posted at

Dockerfileでヒアドキュメントを使用する方法

Dockerfileに以下のように記述することでヒアドキュメントを使用することができます。
ただし、Buildkitを使用している必要があります。

Dockerfile
# syntax=docker/dockerfile:1
ARG RUBY_IMAGE_TAG
FROM ruby:${RUBY_IMAGE_TAG}

ARG PROJECT_NAME
ARG RUBYGEMS_VERSION
ARG USER_NAME=ruby
ENV TZ=Asia/Tokyo

RUN adduser ${USER_NAME}

COPY --chown=${USER_NAME} Gemfile Gemfile.lock /${PROJECT_NAME}/

WORKDIR /${PROJECT_NAME}
RUN <<-EOF
  gem update --system ${RUBYGEMS_VERSION}
  bundle install
  chown -R ${USER_NAME} ${GEM_HOME}
EOF

COPY --chmod=755 /.docker/api/entrypoint.sh /usr/bin/
ENTRYPOINT ["entrypoint.sh"]

USER ${USER_NAME}
RUN mkdir -p /${PROJECT_NAME}/tmp/sockets/

EXPOSE 3000

CMD ["bundle", "exec", "pumactl", "start"]

Dockerfile# syntax=docker/dockerfile:1を記述するのを忘れないようご注意ください。
# syntax=docker/dockerfile:11はバージョンの指定です。

ヒアドキュメントの使用方法は以下をご参照ください。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?