Skip to content

Commit fc7f50b

Browse files
Merge pull request #19 from glensc/fixes
Build: Optimize runner stage in Dockerfile
2 parents dcbd97f + 4d729da commit fc7f50b

2 files changed

Lines changed: 17 additions & 24 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/.idea

Dockerfile

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -83,18 +83,17 @@ RUN ./configure CFLAGS="-ggdb"\
8383
--with-libxslt\
8484
--with-icu\
8585
--with-openssl
86-
86+
8787
RUN make DESTDIR=${BABELFISH_HOME}/ -j ${JOBS} 2>error.txt && make install
8888

8989
WORKDIR ${PG_SRC}/contrib
90-
9190
RUN make -j ${JOBS} && make install
9291

9392
# Compile the ANTLR parser generator
9493
RUN cp /usr/local/lib/libantlr4-runtime.so.${ANTLR4_VERSION}\
9594
${BABELFISH_HOME}/lib
96-
97-
WORKDIR ${PG_SRC}/contrib/babelfishpg_tsql/antlr
95+
96+
WORKDIR ${PG_SRC}/contrib/babelfishpg_tsql/antlr
9897
RUN cmake -Wno-dev .
9998
RUN make all
10099

@@ -113,35 +112,28 @@ RUN make -j ${JOBS} && make PG_CONFIG=${PG_CONFIG} install
113112

114113
# Run stage
115114
FROM base AS runner
116-
ENV DEBIAN_FRONTEND=noninteractive
117115
ENV BABELFISH_HOME=/opt/babelfish
118116
ENV POSTGRES_USER_HOME=/var/lib/babelfish
119-
120-
# Copy binaries to run stage
121-
WORKDIR ${BABELFISH_HOME}
122-
COPY --from=builder ${BABELFISH_HOME} .
117+
EXPOSE 1433 5432
118+
ENTRYPOINT [ "/start.sh" ]
123119

124120
# Install runtime dependencies
125-
RUN apt update && apt install -y --no-install-recommends\
121+
RUN export DEBIAN_FRONTEND=noninteractive && \
122+
apt update && apt install -y --no-install-recommends\
126123
libssl3 openssl libldap-2.5-0 libxml2 libpam0g uuid libossp-uuid16\
127124
libxslt1.1 libicu70 libpq5 unixodbc
128125

126+
RUN adduser postgres --home ${POSTGRES_USER_HOME}
127+
128+
# Copy binaries to run stage
129+
COPY --chmod=755 start.sh /
130+
WORKDIR ${BABELFISH_HOME}
131+
COPY --from=builder --chown=postgres ${BABELFISH_HOME} .
132+
129133
# Enable data volume
130134
ENV BABELFISH_DATA=${POSTGRES_USER_HOME}/data
131-
RUN mkdir -p ${BABELFISH_DATA}
135+
RUN install -d -o postgres -g postgres ${BABELFISH_DATA}
132136
VOLUME ${BABELFISH_DATA}
133137

134-
# Create postgres user
135-
RUN adduser postgres --home ${POSTGRES_USER_HOME}
136-
RUN chown -R postgres ${BABELFISH_HOME}
137-
RUN chown -R postgres ${POSTGRES_USER_HOME}
138-
139-
# Change to postgres user
138+
# Switch runtime user in container
140139
USER postgres
141-
142-
# Expose ports
143-
EXPOSE 1433 5432
144-
145-
# Set entry point
146-
COPY start.sh /
147-
ENTRYPOINT [ "/start.sh" ]

0 commit comments

Comments
 (0)