Skip to content

Commit 29dab46

Browse files
authored
Merge pull request #1 from searchspring/fix-dockerfile
Fix dockerfile
2 parents 0ff7f47 + 445ddb9 commit 29dab46

File tree

1 file changed

+41
-37
lines changed

1 file changed

+41
-37
lines changed

Dockerfile

Lines changed: 41 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
ARG IMAGE_TYPE=full
1+
ARG IMAGE_TYPE=light
22

33
# java-builder: Stage to build a custom JRE (with jlink)
44
FROM python:3.10.5-slim-buster@sha256:807f16dc51eb1ce7ed1178d82ebb60a41ad67fe74840a0bf6bf502368d4bdd47 as java-builder
@@ -204,11 +204,7 @@ RUN TARGETARCH_SYNONYM=$([[ "$TARGETARCH" == "amd64" ]] && echo "x86_64" || echo
204204

205205

206206
# light: Stage which produces a final working localstack image (which does not contain some additional infrastructure like eleasticsearch - see "full" stage)
207-
FROM base-${IMAGE_TYPE}
208-
209-
LABEL authors="LocalStack Contributors"
210-
LABEL maintainer="LocalStack Team (info@localstack.cloud)"
211-
LABEL description="LocalStack Docker image"
207+
FROM base-${IMAGE_TYPE} as flatten
212208

213209
# Copy the build dependencies
214210
COPY --from=builder /opt/code/localstack/ /opt/code/localstack/
@@ -217,46 +213,54 @@ COPY --from=builder /opt/code/localstack/ /opt/code/localstack/
217213
COPY --from=builder /usr/share/postgresql/11/extension /usr/share/postgresql/11/extension
218214
COPY --from=builder /usr/lib/postgresql/11/lib /usr/lib/postgresql/11/lib
219215

220-
RUN mkdir -p /tmp/localstack && \
221-
if [ -e /usr/bin/aws ]; then mv /usr/bin/aws /usr/bin/aws.bk; fi; ln -s /opt/code/localstack/.venv/bin/aws /usr/bin/aws
216+
ADD localstack/ localstack/
222217

223-
# fix some permissions and create local user
224-
RUN mkdir -p /.npm && \
218+
ARG LOCALSTACK_PRE_RELEASE=1
219+
220+
RUN mkdir -p /tmp/localstack && \
221+
if [ -e /usr/bin/aws ]; then mv /usr/bin/aws /usr/bin/aws.bk; fi; ln -s /opt/code/localstack/.venv/bin/aws /usr/bin/aws && \
222+
# fix some permissions and create local user
223+
mkdir -p /.npm && \
225224
chmod 777 . && \
226225
chmod 755 /root && \
227226
chmod -R 777 /.npm && \
228227
chmod -R 777 /tmp/localstack && \
229228
useradd -ms /bin/bash localstack && \
230-
ln -s `pwd` /tmp/localstack_install_dir
231-
232-
# Install the latest version of awslocal globally
233-
RUN pip3 install --upgrade awscli awscli-local requests
234-
235-
# Add the code in the last step
236-
# Also adds the results of `make init` to the container.
237-
# `make init` _needs_ to be executed before building this docker image (since the execution needs docker itself).
238-
ADD localstack/ localstack/
239-
240-
# Download some more dependencies (make init needs the LocalStack code)
241-
# FIXME the init python code should be independent (i.e. not depend on the localstack code), idempotent/reproducible,
242-
# modify only folders outside of the localstack package folder, and executed in the builder stage.
243-
RUN make init
244-
245-
# Install the latest version of localstack-ext and generate the plugin entrypoints.
246-
# If this is a pre-release build, also include dev releases of these packages.
247-
ARG LOCALSTACK_PRE_RELEASE=1
248-
RUN (PIP_ARGS=$([[ "$LOCALSTACK_PRE_RELEASE" == "1" ]] && echo "--pre" || true); \
229+
ln -s `pwd` /tmp/localstack_install_dir && \
230+
# Install the latest version of awslocal globally
231+
pip3 install --upgrade awscli awscli-local requests && \
232+
# `make init` _needs_ to be executed before building this docker image (since the execution needs docker itself).
233+
# Download some more dependencies (make init needs the LocalStack code)
234+
# FIXME the init python code should be independent (i.e. not depend on the localstack code), idempotent/reproducible,
235+
# modify only folders outside of the localstack package folder, and executed in the builder stage.
236+
make init && \
237+
# Install the latest version of localstack-ext and generate the plugin entrypoints.
238+
# If this is a pre-release build, also include dev releases of these packages.
239+
(PIP_ARGS=$([[ "$LOCALSTACK_PRE_RELEASE" == "1" ]] && echo "--pre" || true); \
249240
virtualenv .venv && source .venv/bin/activate && \
250-
pip3 install --upgrade ${PIP_ARGS} localstack-ext plux)
251-
RUN make entrypoints
241+
pip3 install --upgrade ${PIP_ARGS} localstack-ext plux) && \
242+
pip3 uninstall pip3 && \
243+
make entrypoints && \
244+
apt-get remove -y \
245+
gcc \
246+
g++ \
247+
git \
248+
groff-base \
249+
make && \
250+
apt-get clean -y && \
251+
apt-get autoremove -y
252+
253+
#-----------------------
254+
FROM scratch as target
255+
COPY --from=flatten / /
252256

253257
# Add the build date and git hash at last (changes everytime)
254-
ARG LOCALSTACK_BUILD_DATE
255-
ARG LOCALSTACK_BUILD_GIT_HASH
256-
ARG LOCALSTACK_BUILD_VERSION
257-
ENV LOCALSTACK_BUILD_DATE=${LOCALSTACK_BUILD_DATE}
258-
ENV LOCALSTACK_BUILD_GIT_HASH=${LOCALSTACK_BUILD_GIT_HASH}
259-
ENV LOCALSTACK_BUILD_VERSION=${LOCALSTACK_BUILD_VERSION}
258+
ARG LOCALSTACK_BUILD_DATE \
259+
LOCALSTACK_BUILD_GIT_HASH \
260+
LOCALSTACK_BUILD_VERSION
261+
ENV LOCALSTACK_BUILD_DATE=${LOCALSTACK_BUILD_DATE} \
262+
LOCALSTACK_BUILD_GIT_HASH=${LOCALSTACK_BUILD_GIT_HASH} \
263+
LOCALSTACK_BUILD_VERSION=${LOCALSTACK_BUILD_VERSION}
260264

261265
# expose edge service, external service ports, and debugpy
262266
EXPOSE 4566 4510-4559 5678

0 commit comments

Comments
 (0)