-
Notifications
You must be signed in to change notification settings - Fork 3
Introduce multi stage builds #28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
yutaro-sakamoto
wants to merge
5
commits into
main
Choose a base branch
from
multi-stage-build
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
e495f99
build: introduce multi stage builds
yutaro-sakamoto 0d39664
change: introduce multi stage builds into utf8.Dockerfile
yutaro-sakamoto a945b00
fix: Dockerfile and utf8.Dockerfile
yutaro-sakamoto 3cc9bc5
fix: a COPY command in Dockerfile
yutaro-sakamoto b2220e5
Update utf8.Dockerfile
yutaro-sakamoto File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,78 @@ | ||
FROM almalinux:9 | ||
# Builder stage | ||
FROM almalinux:9 AS builder | ||
|
||
SHELL ["/bin/bash", "-c"] | ||
|
||
# classpath settings | ||
ENV CLASSPATH=:/usr/lib/opensourcecobol4j/libcobj.jar:/usr/lib/Open-COBOL-ESQL-4j/postgresql.jar:/usr/lib/opensourcecobol4j/ocesql4j.jar | ||
RUN echo 'export CLASSPATH=:/usr/lib/opensourcecobol4j/libcobj.jar:/usr/lib/Open-COBOL-ESQL-4j/postgresql.jar:/usr/lib/Open-COBOL-ESQL-4j/ocesql4j.jar' >> ~/.bashrc | ||
# Install build dependencies | ||
RUN dnf update -y && \ | ||
dnf install -y gcc make bison flex automake autoconf diffutils gettext java-11-openjdk-devel gzip tar && \ | ||
dnf clean all | ||
|
||
# install dependencies | ||
RUN dnf update -y | ||
RUN dnf install -y gcc make bison flex automake autoconf diffutils gettext java-11-openjdk-devel | ||
# Install sbt | ||
RUN curl -fL https://github.com/coursier/coursier/releases/latest/download/cs-x86_64-pc-linux.gz | gzip -d > cs && \ | ||
chmod +x cs && \ | ||
echo Y | ./cs setup | ||
|
||
# install sbt | ||
RUN curl -fL https://github.com/coursier/coursier/releases/latest/download/cs-x86_64-pc-linux.gz | gzip -d > cs && chmod +x cs && echo Y | ./cs setup | ||
# Set PATH for sbt | ||
ENV PATH="$PATH:/root/.local/share/coursier/bin" | ||
|
||
# install opensourcecobol4j | ||
RUN cd /root &&\ | ||
curl -L -o opensourcecobol4j-v1.1.7.tar.gz https://github.com/opensourcecobol/opensourcecobol4j/archive/refs/tags/v1.1.7.tar.gz &&\ | ||
tar zxvf opensourcecobol4j-v1.1.7.tar.gz &&\ | ||
cd opensourcecobol4j-1.1.7 &&\ | ||
./configure --prefix=/usr/ &&\ | ||
make &&\ | ||
make install &&\ | ||
rm /root/opensourcecobol4j-v1.1.7.tar.gz | ||
# Build opensourcecobol4j | ||
RUN cd /tmp && \ | ||
curl -L -o opensourcecobol4j-v1.1.9.tar.gz https://github.com/opensourcecobol/opensourcecobol4j/archive/refs/tags/v1.1.9.tar.gz && \ | ||
tar zxf opensourcecobol4j-v1.1.9.tar.gz && \ | ||
cd opensourcecobol4j-1.1.9 && \ | ||
./configure --prefix=/usr/ && \ | ||
make && \ | ||
make install | ||
|
||
# Install Open COBOL ESQL 4J | ||
ENV PATH="$PATH:/root/.local/share/coursier/bin" | ||
RUN mkdir -p /usr/lib/Open-COBOL-ESQL-4j &&\ | ||
cd /root/ &&\ | ||
curl -L -o Open-COBOL-ESQL-4j-1.1.1.tar.gz https://github.com/opensourcecobol/Open-COBOL-ESQL-4j/archive/refs/tags/v1.1.1.tar.gz &&\ | ||
tar zxvf Open-COBOL-ESQL-4j-1.1.1.tar.gz &&\ | ||
rm Open-COBOL-ESQL-4j-1.1.1.tar.gz &&\ | ||
cd Open-COBOL-ESQL-4j-1.1.1 &&\ | ||
mkdir -p /usr/lib/Open-COBOL-ESQL-4j/ &&\ | ||
curl -L -o /usr/lib/Open-COBOL-ESQL-4j/postgresql.jar https://jdbc.postgresql.org/download/postgresql-42.2.24.jar &&\ | ||
cp /usr/lib/opensourcecobol4j/libcobj.jar dblibj/lib &&\ | ||
cp /usr/lib/Open-COBOL-ESQL-4j/postgresql.jar dblibj/lib &&\ | ||
./configure --prefix=/usr/ &&\ | ||
make &&\ | ||
make install &&\ | ||
rm -rf /root/Open-COBOL-ESQL-4j-1.1.1 | ||
|
||
# add sample programs | ||
# Build Open COBOL ESQL 4J | ||
RUN mkdir -p /usr/lib/Open-COBOL-ESQL-4j && \ | ||
cd /tmp && \ | ||
curl -L -o Open-COBOL-ESQL-4j-1.1.1.tar.gz https://github.com/opensourcecobol/Open-COBOL-ESQL-4j/archive/refs/tags/v1.1.1.tar.gz && \ | ||
tar zxf Open-COBOL-ESQL-4j-1.1.1.tar.gz && \ | ||
cd Open-COBOL-ESQL-4j-1.1.1 && \ | ||
curl -L -o /usr/lib/Open-COBOL-ESQL-4j/postgresql.jar https://jdbc.postgresql.org/download/postgresql-42.2.24.jar && \ | ||
cp /usr/lib/opensourcecobol4j/libcobj.jar dblibj/lib && \ | ||
cp /usr/lib/Open-COBOL-ESQL-4j/postgresql.jar dblibj/lib && \ | ||
./configure --prefix=/usr/ && \ | ||
make && \ | ||
make install | ||
|
||
# Runtime stage | ||
FROM almalinux:9 | ||
|
||
SHELL ["/bin/bash", "-c"] | ||
|
||
# Install only runtime dependencies | ||
RUN dnf update -y && \ | ||
dnf install -y java-11-openjdk-headless && \ | ||
dnf clean all | ||
|
||
# Copy installed files from builder | ||
# Copy opensourcecobol4j executables | ||
COPY --from=builder /usr/bin/cobj /usr/bin/ | ||
COPY --from=builder /usr/bin/cobjrun /usr/bin/ | ||
COPY --from=builder /usr/bin/cob-config /usr/bin/ | ||
COPY --from=builder /usr/bin/cobj-idx /usr/bin/ | ||
COPY --from=builder /usr/bin/cobj-api /usr/bin/ | ||
# Copy Open COBOL ESQL 4J executable | ||
COPY --from=builder /usr/bin/ocesql /usr/bin/ | ||
# Copy JAR libraries | ||
COPY --from=builder /usr/lib/opensourcecobol4j/ /usr/lib/opensourcecobol4j/ | ||
COPY --from=builder /usr/lib/Open-COBOL-ESQL-4j/ /usr/lib/Open-COBOL-ESQL-4j/ | ||
# Copy configuration and copy files | ||
COPY --from=builder /usr/share/opensource-cobol-4j-1.1.9/ /usr/share/opensource-cobol-4j-1.1.9/ | ||
# Copy header file | ||
COPY --from=builder /usr/include/libcobj.h /usr/include/ | ||
|
||
# Set classpath | ||
ENV CLASSPATH=:/usr/lib/opensourcecobol4j/libcobj.jar:/usr/lib/Open-COBOL-ESQL-4j/postgresql.jar:/usr/lib/Open-COBOL-ESQL-4j/ocesql4j.jar | ||
RUN echo 'export CLASSPATH=:/usr/lib/opensourcecobol4j/libcobj.jar:/usr/lib/Open-COBOL-ESQL-4j/postgresql.jar:/usr/lib/Open-COBOL-ESQL-4j/ocesql4j.jar' >> ~/.bashrc | ||
|
||
# Add sample programs | ||
ADD cobol_sample /root/cobol_sample | ||
ADD ocesql4j_sample /root/ocesql4j_sample | ||
|
||
WORKDIR /root/ | ||
|
||
CMD ["/bin/bash"] | ||
CMD ["/bin/bash"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,63 @@ | ||
# Builder stage | ||
FROM almalinux:9 AS builder | ||
|
||
SHELL ["/bin/bash", "-c"] | ||
|
||
# Install build dependencies | ||
RUN dnf update -y && \ | ||
dnf install -y gcc make bison flex automake autoconf diffutils gettext java-11-openjdk-devel gzip tar && \ | ||
dnf clean all | ||
|
||
# Install sbt | ||
RUN curl -fL https://github.com/coursier/coursier/releases/latest/download/cs-x86_64-pc-linux.gz | gzip -d > cs && \ | ||
chmod +x cs && \ | ||
echo Y | ./cs setup | ||
|
||
# Set PATH for sbt | ||
ENV PATH="$PATH:/root/.local/share/coursier/bin" | ||
|
||
# Build opensourcecobol4j with UTF-8 support | ||
RUN cd /tmp && \ | ||
curl -L -o opensourcecobol4j-v1.1.9.tar.gz https://github.com/opensourcecobol/opensourcecobol4j/archive/refs/tags/v1.1.9.tar.gz && \ | ||
tar zxf opensourcecobol4j-v1.1.9.tar.gz && \ | ||
cd opensourcecobol4j-1.1.9 && \ | ||
./configure --prefix=/usr/ --enable-utf8 && \ | ||
touch cobj/*.m4 && \ | ||
make && \ | ||
make install | ||
|
||
# Runtime stage | ||
FROM almalinux:9 | ||
|
||
SHELL ["/bin/bash", "-c"] | ||
|
||
# classpath settings | ||
# Install only runtime dependencies | ||
RUN dnf update -y && \ | ||
dnf install -y java-11-openjdk-headless && \ | ||
dnf clean all | ||
|
||
# Copy installed files from builder | ||
# Copy opensourcecobol4j executables | ||
COPY --from=builder /usr/bin/cobj /usr/bin/ | ||
COPY --from=builder /usr/bin/cobjrun /usr/bin/ | ||
COPY --from=builder /usr/bin/cob-config /usr/bin/ | ||
COPY --from=builder /usr/bin/cobj-idx /usr/bin/ | ||
COPY --from=builder /usr/bin/cobj-api /usr/bin/ | ||
# Copy JAR libraries | ||
COPY --from=builder /usr/lib/opensourcecobol4j/ /usr/lib/opensourcecobol4j/ | ||
# Copy configuration and copy files | ||
COPY --from=builder /usr/share/opensource-cobol-4j-1.1.9/ /usr/share/opensource-cobol-4j-1.1.9/ | ||
# Copy header file | ||
COPY --from=builder /usr/include/libcobj.h /usr/include/ | ||
|
||
# Set classpath | ||
ENV CLASSPATH=:/usr/lib/opensourcecobol4j/libcobj.jar | ||
RUN echo 'export CLASSPATH=:/usr/lib/opensourcecobol4j/libcobj.jar' >> ~/.bashrc | ||
|
||
# install dependencies | ||
RUN dnf update -y | ||
RUN dnf install -y gcc make bison flex automake autoconf diffutils gettext java-11-openjdk-devel | ||
|
||
# install sbt | ||
RUN curl -fL https://github.com/coursier/coursier/releases/latest/download/cs-x86_64-pc-linux.gz | gzip -d > cs && chmod +x cs && echo Y | ./cs setup | ||
|
||
# install opensourcecobol4j | ||
RUN cd /root &&\ | ||
curl -L -o opensourcecobol4j-v1.1.7.tar.gz https://github.com/opensourcecobol/opensourcecobol4j/archive/refs/tags/v1.1.7.tar.gz &&\ | ||
tar zxvf opensourcecobol4j-v1.1.7.tar.gz &&\ | ||
cd opensourcecobol4j-1.1.7 &&\ | ||
./configure --prefix=/usr/ --enable-utf8 &&\ | ||
touch cobj/*.m4 &&\ | ||
make &&\ | ||
make install &&\ | ||
rm /root/opensourcecobol4j-v1.1.7.tar.gz | ||
|
||
# add sample programs | ||
# Add sample programs | ||
ADD cobol_sample /root/cobol_sample | ||
|
||
WORKDIR /root/ | ||
|
||
CMD ["/bin/bash"] | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.